Massively reduce query counts when performing search indexes.
Review Request #8918 — Created May 1, 2017 and submitted
We were performing numerous queries for every user or review request
being indexed. This led to slowdowns when performing large indexes, or
on slower search backends.
We now make full use of select_related() and prefetch_related(),
iterating over the cached results instead of performing new queries to
For 100 users, this should reduce the query count from 201 queries to 3.
For 100 review requests, the query count should be reduced from 402 to
Tested a full search index with queries turned on. Saw that we no longer
had per-item queries, and that all content was being indexed properly.