[freetds] dbnextrow() vs dbskiprow() (skipping rows in FreeTDS)

James K. Lowden jklowden at freetds.org
Mon Jul 28 10:11:44 EDT 2008

Navdeep Shergill wrote:
> Currently everytime I call dbnextrow(); the results of the row are
> loaded into memory so that I can retrieve them. I am looking for a
> functionality that will allow me to do a 'skip row'. Basically advance
> the row counter by 1 without actually loading the data in memory. 

There would be no advantage to such a function.  

db-lib fetches the rows from the server serially.  The time needed to copy
bound buffers is nil compared to the time to create the row on the server
and to transmit it over the wire.  If you don't believe me, try fetching
1,000,000 rows with and without calling dbbind().  

Of the creation and transmission steps, creation is by far the more
expensive.  That is why you're getting advice not to create the row in the
first place by redoing your SQL.  

To avoid transmission of rows already created, the client would have to
tell the server which rows to send.  There is no provision for that
operation in the TDS protocol.  (That tells us something, doesn't it?) 

I would argue that what you want isn't efficiency but convenience. 
Convenience you can have: just write your function.  You can do so with a
clear conscience knowing there's no efficiency gain to be had.  



More information about the FreeTDS mailing list