Okay, so I'm stumped on a problem that i've done a million times, but this time I want to do correctly.
Simply page navigation for searches, limiting number of rows per page.
Of course I need to know the number of rows matched, but also limit the number of rows queried.
The problem of course being select * from blah limit x,y, my mysql_num_rows($query) will be y if y or more rows are found, so I cant divide the pages.
I'm running this on an indexed, but still rather large table with query times .12 each.
So for me to run 2 queries, 1 to count and 1 to retrieve would be impractical as each request would at to about .25 seconds, or 4 requests per second, with alot of uses on a high usage table this is certainly a trouble spot.
I'm thinking of using EXPLAIN on the count and retrieving rows info, but of course that count isnt always accurate.
Any suggestions on how to go about this problem?
Actually, I just realized, the EXPLAIN count will return the number of rows examined, not matched, so it's useless