I have a dataset in MySQL, where using a limit is already an expensive query, and finding the number of results is also expensive. So I would like to avoid another query to find the number of results. I cannot use MYSQL_CALC_FOUND_ROWS because the limit is inside the subquery:
SELECT * FROM items, ( SELECT item_id FROM (etc) WHERE some.field=<parameter> AND (etc) GROUP BY (something) ORDER BY (something_else) DESC LIMIT 15 ) subset WHERE item.id=subset.item_id
I could leave the connection elements and end the subquery and then use MYSQL_CALC_FOUND_ROWS, however this is very, very, slow. I tried index optimization and let me just assume that this is out of the question.
Now this is becoming a design issue ... How can I allow the user to view this data when I do not know the last page ? I only know if they went too far (for example: the query returns no results).
source share