> SELECT * from test WHERE PK1>100 AND PK1<200;>> SELECT * from test WHERE 
> PK1>100 LIMIT 100;>> Will the above queries have the same effect? Or will 
> LIMIT behave> differently, i.e. get the entire result set and then return the 
> first 100> from it?
If your PK1 has no gaps then those two queries will behave almost
identically (except that first one selects 99 rows and second one -
100). If PK1 has gaps then as you've figured out these queries behave
differently.
Also SQLite never does such thing as "select entire result set and
then return it to you row-by-row". In fact SQLite process your select
row-by-row as you call sqlite3_step(). So you can execute query with
LIMIT 100 but after 3rd row call sqlite3_finalize() and performance of
your program will be the same as if you queried LIMIT 3 from the very
beginning.


Pavel


On Fri, Oct 7, 2011 at 11:24 AM, cricketfan <srtedul...@yahoo.co.in> wrote:
>
> I have a table called test and it has about 50 columns ( about 200 bytes of
> data, all columns combined). I need to browse the entire table periodically.
> I have a primary key PK1 which basically is a increasing
> sequence number.
>
> SELECT * from test WHERE PK1>100 AND PK1<200;
>
> SELECT * from test WHERE PK1>100 LIMIT 100;
>
> Will the above queries have the same effect? Or will LIMIT behave
> differently, i.e. get the entire result set and then return the first 100
> from it?
>
> I delete records in my table (it is like a queue implementation) so I might
> have gaps in between which is why I want to use the LIMIT clause.
>
> Any advice would be greatly appreciated.
> --
> View this message in context: 
> http://old.nabble.com/SQLITE-LIMIT-clause-tp32607006p32607006.html
> Sent from the SQLite mailing list archive at Nabble.com.
>
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to