Optimize querying with private review requests.

Review Request #5669 — Created April 2, 2014 and submitted — Latest diff uploaded

Information

Review Board
release-1.7.x
0ebf9b5...

Reviewers

When querying lists of review requests that contained private review
requests, the query ended up joining enough tables where the query could
take a substantial amount of time to execute.

This change optimizes the query by pulling out a couple of the more
expensive joins into a couple simple queries. The result is a much
faster query.

All unit tests passed.

Ran some sample queries on reviews.reviewboard.org, and saw the speed
differences.