[freetds] absolute fetches

Thompson, Bill D (London) ThompBil at exchange.uk.ml.com
Tue Apr 8 04:13:53 EDT 2003


Hi,

I've worked out the required "wire protocol" for SQL server cursors of all
types - forward/backward/rowset/keyed - but this awaits implementation..
My aim is to put this in first for the ct-library cursor calls, but it
should be available for the ODBC driver when complete.

Bill


> -----Original Message-----
> From:	James K. Lowden [SMTP:jklowden at schemamania.org]
> Sent:	08 April 2003 09:03
> To:	FreeTDS Development Group
> Subject:	Re: [freetds] absolute fetches
> 
> On Mon, 07 Apr 2003 17:09:52 -0400, Jon Pounder <JonP at inline.net> wrote:
> > 
> > Ok, is there any other way then to quickly run through the first n
> > records and throw away the results ?
> > 
> > eg: I want rows 100 to 110, from looking at the code now, I gather than
> > to implement this, rows 1 to 99 are actually all transferred from the db
> > 
> > server to the driver and then thrown away, is there any facility for
> > doing a fetch_next without actually transferring the data ?
> 
> No, Jon, there's not.  The TDS protocol is a pipe.  You send it a query;
> it sends you results.  The results don't live *anywhere* except in the
> pipe.  Unlike other database systems (of which I know only a little),
> there's no server-side memory cache for the client library to talk to. 
> The server simply selects the rows you specify, and shoots them out the
> pipe.  Or dribbles, as the case may be.  
> 
> That's why you can't know the rowcount until the query's been processed
> and the rows fetched.  The server doesn't itself know how many rows there
> were until it shipped them all.  
> 
> As Frediano said, there are several SQL techniques to compensate:
> temporary tables with identity columns, T-SQL cursors, even (ugh!) the
> "top" modifier, lately.  However, except in unusual circumstances, none of
> these will be faster than simply reading and discarding the rows you're
> trying to skip.  
> 
> --jkl
> _______________________________________________
> FreeTDS mailing list
> FreeTDS at lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/freetds



More information about the FreeTDS mailing list