Re: Alternative to FOUND_ROWS()
Posted by: Rick James
Date: February 10, 2009 12:08AM

No direct alternative. Here are some thoughts.

SELECT 1 FROM tbl LIMIT 1000,1;
If it returns 1, you have at least 1000 rows.
If it does not return, then proceed to do
knowing that it won't hit more than 1000 rows; furthermore, it will (usually) pick the smallest index to do the counting.

In MyISAM, "SELECT COUNT(*) FROM tbl" is instantaneous. In InnoDB, it has to walk through an index (or the data).

Another trick...
will, among other things, give you the number of rows in the table (exactly for MyISAM, approx for InnoDB). For InnoDB, this would be even faster than LIMIT 1000,1, but not as precise. (It can be off by a factor of two.)

Options: ReplyQuote

Written By
February 08, 2009 01:07PM
Re: Alternative to FOUND_ROWS()
February 10, 2009 12:08AM
February 11, 2009 10:21AM
February 14, 2009 01:15PM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.