django/django — pull request #3260 by tchaumeny (2014-09-22 17:16:24+00:00)
Title: Fixed #8408 -- Provide ModelAdmin option to avoid expensive COUNT()

A full `SELECT COUNT(*) FROM "foo"` is performed on admin pages even when the current list being displayed is restricted to a small subset of entries.

This extra query result — which can be very expensive on large tables as explained in https://code.djangoproject.com/ticket/8408 — is used for two purposes:

1. Displaying a "99 results (103 total)" link next to the search field
2. Determining whether the table contains at least one entry so that the actions form is shown.

With this PR, if `ModelAdmin.show_full_result_count` is set to `False`, the link in 1 is replaced by "99 results (See all)" and the actions form is always shown — which shouldn't be a problem.

Also, I think https://code.djangoproject.com/ticket/8851 could be a next step after that, as it would allow the default admin page for models with many instances to be filtered by default, so that it doesn't take too long to load.