joomla/joomla-platform — pull request #1532 by mahagr (2012-09-15 18:38:17+00:00)
Title: Fix performance issues in JModelLegacy::_getListCount()

Current code in JModelLegacy::_getListCount() forces database engine to fetch all items instead of just counting them. With hundreds of thousands or millions of rows the query gets very inefficient even if no results are actually fetched by the function.

Cloning and modifying JDatabaseQuery object into COUNT(*) allows database engine to do optimizations that will considerably speed up the code even with very simple queries like:

SELECT * FROM jos_users

if there are hundreds of thousands of users.