Massively reduce query counts when performing search indexes.

Review Request #8918 — Created May 1, 2017 and submitted — Latest diff uploaded

Information

Review Board
release-2.5.x
59b3c64...

Reviewers

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
filter content.

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
5.

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.