Jump to content

SELECT SQL_CALC_FOUND_ROWS


jonniejoejonson

Recommended Posts

mysql> SELECT SQL_CALC_FOUND_ROWS * FROM tbl_name

    -> WHERE id > 100 LIMIT 10;

mysql> SELECT FOUND_ROWS();

 

 

Is this faster than if I created a second query that simply counted the rows without the LIMIT.

 

i.e.. when you use SELECT SQL_CALC_FOUND_ROWS, does it actually select all the records in the table that are not within the limit, or does it just COUNT the number of rows that are not within the limit, because by selecting them all it is going to slow it down... any ideas regards J.

Link to comment
Share on other sites

I've had good luck with this, and it is faster because you would be making Mysql re-query again, see the use of limit means mysql still has to query all the data and then subset it out for the limit, so the "sql_calc_found_rows" just does a quick count of rows before the limit is applied.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.