I'm trying to speed up some SQL queries. My SQL query on pagination is like this (3rd page):
SELECT
SQL_CALC_FOUND_ROWS book_id, book_title
FROM
books
LIMIT 40, 60
And then getting all result count:
SELECT FOUND_ROWS();
But if the result count is huge (milions of books) then FOUND_ROWS()
can took very long time.
The fact is that there is no need to count milions of rows (books) and the answer "10000+" is enough for usual user.
Is possible something like this? Pseudocode:
SELECT FOUND_ROWS(LIMIT 10000)