Quantcast
Viewing all articles
Browse latest Browse all 295117

Add support for database hints and make PagerDefault properly pluggeable

The current implementation of a pager query always runs TWO queries against actual data. MySQL allows you to grab the total number of rows that would have been returned if no LIMIT was present by adding the "SQL_CALC_FOUND_ROWS" statement in your SELECT query.

This causes MySQL to return the normal result set and store the full number of matching records in a variable, which can then easily be retrieved via the FOUND_ROWS() function.

Ie:

SELECT SQL_CALC_FOUND_ROWS nid, title from {node} LIMIT 500,10;
SELECT FOUND_ROWS();

As it stands, the database layer doesn't really allow us to make use of this sort of functionality, but it would be nice if it did. For large tables there is a potentially large performance gain, especially when many changes are made to the data being paged through, as the count query can't be cached in such a case.

I don't doubt that other databases have their own versions of these sorts of tricks, for various kinds of queries and I wonder if it might be worth modifying the database layer to be able to make use of them.


Viewing all articles
Browse latest Browse all 295117

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>