I have a very common problem, but cannot seem to find a good answer for it.
I need to get a page's worth of rows from a table, as well as enough info to paginate this data. So in general I need a very rough estimate of the total number of rows (in general All I need to know is ceil(count()/50)
).
So count()
is really overkill. And I already have a SELECT * FROM table LIMIT 0, 50
running, so if it can be appended to this command all the better.
I have heard about SQL_CALC_FOUND_ROWS
. But I also heard that it is not particularly more efficient than just doing the count
yourself. "Unfortunately, using SQL_CALC_FOUND_ROWS has the nasty consequence of blowing away any LIMIT optimization that might happen".
So, all in all, I kindof think using MySQL's row estimate is the way to go. But I do not know how to do that. Or how off this estimate might be.
Note1: In my situation most of the tables I am working with are just updated a few times a day, not all the time. Note2: I am using PDO with php.