MySQL Forums
Forum List  »  Router & Proxy

Getting Result Set Size
Posted by: Mike Patrick
Date: October 16, 2009 01:53PM

I have been trying to calculate the size in bytes of a result set. This is based on the bandwidth calculation example. It seems to work at first and then eventually, the row values become nil. It seems to be also at a random number of rows even if I re-run it with the exact same data. Any help would be GREATLY appreciated!

BTW, I added a row count to be sure it was going through all of the rows and it is.

Below is the code I am using:

local bandwidth = 0

function read_query (packet )
bandwidth = bandwidth + string.len(packet)
proxy.queries:append(1, packet)
return proxy.PROXY_SEND_QUERY
end

function read_query_result(inj)
local rows = inj.resultset.rows
local fields = inj.resultset.fields
local rowcount = 0
local numcols = #inj.resultset.fields

if fields then
for i = 1, #fields do
bandwidth = bandwidth + (fields and fields.name:len() or 0)
end

if rows then
for row in inj.resultset.rows do
rowcount = rowcount + 1

for i = 1, numcols do
print (row)
bandwidth = bandwidth + (row and row:len() or 0)
end
end
end
print ("Row Count: " .. rowcount)
print ("Bandwidth:" .. bandwidth)
end
end

Thanks,
Mike

Options: ReplyQuote


Subject
Views
Written By
Posted
Getting Result Set Size
9491
October 16, 2009 01:53PM
3122
October 16, 2009 02:00PM
3613
October 29, 2009 11:20AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.