django/django — pull request #881 by acdha (2013-03-05 17:33:50+00:00)
Title: Admin: make search filter construction O(1)

Using the database this way is inherently slow but the previous implementation
would call QuerySet.filter() once per whitespace-separated term in the query
text, causing an extra set of JOINs for each term. With the MySQL backend,
this actually causes database errors once you hit the server limit of 61.

This commit makes two changes: the first is simply to filter the queryset only
once; the second is to only process unique terms in the search field.