MySQL pagination without double-querying? -
I was thinking that there was a way to get the number of results from a MySQL query, and the results at the same timeframe .
The way the pagination works (as I think), first I get the `table 'from
query = SELECT COUNT (*) Where 'some_condition` I get num_rows (query), I have the number of results but then actually to limit my results, make me like another query Will be: `table 'from <2 p>
query2 = SELECT COUNT (*) where' some_condition` range 0, 10 My question: Anyway, bothWhat happens to retrieving the total number of results and limiting the results given in the same question? Or any more efficient way of doing so thanks!
No, how many applications are it that you want to endorse, it is reliable and bullet proof, Although it creates a query twice but you can cache the count for a few seconds and it will be very helpful.
On the other side use the SQL_CALC_FOUND_ROWS section and then call SELECT FOUND_ROWS () . Apart from this, you have to call FOUND_ROWS () , then there is a problem: it is that tickling ORDER BY affects questions, which makes it very slow
Comments
Post a Comment