Wout Mertens wrote:
> To do paged queries on a query like
>
>     SELECT colVal FROM t WHERE b=? LIMIT 10

This does not make sense without an ORDER BY.

> To know how many rows there are in the query, I do
>
>     SELECT COUNT(*) FROM t WHERE b=?
>
> Are there any efficiency tricks here?

No.  SQLite computes rows on demand, so without the COUNT(*) query,
it never even goes to the last rows.

> Is it better to run the count before the query or vice versa?

There is unlikely to be any noticable difference.

(If there might be concurrent queries that modify the data, you should
use a transaction to get consistent results.)


Regards,
Clemens
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to