List:MySQL on Win32« Previous MessageNext Message »
From:Paul DuBois Date:July 23 2001 11:55pm
Subject:Re: LIMIT clause question
View as plain text  
At 4:52 PM -0700 7/23/01, Joe Bob wrote:
>The story is too long to get into, but between various
>third-party stuff and MyODBC, it turns out that I am
>really forced into doing a SELECT to get some table
>schema info populated into my recordset in my program.
>
>I don't really care to have any data back, as I will
>be doing a bunch of inserts, but if I can get the
>schema into my recordset, then it will build all the
>INSERT statments for me as I invoke Add methods on it.
>
>My question is one of performance.  I have been
>successful at getting the recordset to conform to my
>table schema by specifying a hookup like
>
>SELECT Id, Description FROM items LIMIT 0;
>
>When you tell MySQL to LIMIT the records, will it
>actually short-circuit, and realize the LIMIT is zero,
>thus simply going and fetching the empty data set and
>schema to return via ODBC to my prog.

It's probably more efficient to do this:

SELECT Id, Description FROM items WHERE 1 = 0

>
>OR, will the query go hammer the DB, fetch a billion
>item rows (or whatever, you get the picture), then
>trim that resultset down to 0 for a return.
>
>Any insight into this would be helpful.
>
>It could make a difference to whether I use the
>recordset construct with its command batching scheme,
>or whether I say "heck with it" and just simply read
>in/transform records, looping through them and
>building string "INSERT" commands and executing them
>one by one.
>
>Thanks


-- 
Paul DuBois, paul@stripped
Thread
LIMIT clause questionJoe Bob24 Jul
  • Re: LIMIT clause questionPaul DuBois24 Jul
    • Re: LIMIT clause questionCynic25 Jul