SQL_CALC_FOUND_ROWS

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

SQL_CALC_FOUND_ROWS

gammal.sqlite
Hi,
I'm wondering if sqlite has something similar to MySQL's SQL_CALC_FOUND_ROWS. I'm sorry if this topic has been discussed before, but I've searched the archives and found no final decision made about it yet...

TIA,
Mahmoud Al Gammal


----------
This message was sent from a MailNull anti-spam account.  You can get
your free account and take control over your email by visiting the
following URL.

   http://mailnull.com/
Reply | Threaded
Open this post in threaded view
|

Re: SQL_CALC_FOUND_ROWS

Igor Tandetnik
Mahmoud Al Gammal wrote:
> I'm wondering if sqlite has something similar to MySQL's
> SQL_CALC_FOUND_ROWS. I'm sorry if this topic has been discussed
> before, but I've searched the archives and found no final decision
> made about it yet...

With SQLite, there's no point doing that. You may just as well run the
query without LIMIT clause.

In MySQL, SQL_CALC_FOUND_ROWS works essentially by running the full
query as if issued without the LIMIT clause, but then only sending first
X records over to the client. The time saving comes from not sending
extra data over the wire, not from more efficient query execution.

SQLite works in-process and does not read the column data until you
explicitly request it. To imitate SQL_CALC_FOUND_ROWS, simply run the
query without LIMIT, read the actual data from the first X rows then
simply step through the rest to count them.

Igor Tandetnik