Optimize the number of queries for the Diff Size column.

Review Request #8879 — Created April 6, 2017 and submitted

Christian Hammond
Review Board
The Diff Size column was doing a query on the DiffSetHistory,
latest DiffSet, and all FileDiffs for each and every review request.
This wasn't great for performance.

This change adds prefetching for the diffsets and filediffs, reducing
the queries substantially. We still do need the filediffs, since total
line counts aren't cached on the diffset (and even if they were, we'd
still need to make the filediffs query for those not cached). It's still
one of the more expensive columns, but far less than it used to be.

Unit tests pass.

Inspected the SQL statements for the datagrid. Saw that there were no
longer large numbers of queries.

David Trowbridge
  1. Ship It!
Christian Hammond
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-2.0.x (93a43d3)