Reduce queries on datagrids by pre-populating a cache of fetched objects.

Review Request #3218 — Created July 15, 2012 and submitted — Latest diff uploaded

Information

Djblets
release-0.6.x

Reviewers

Reduce queries on datagrids by pre-populating a cache of fetched objects.

Many columns on the datagrid render related objects, such as a user. We
had a cache in place that would prevent duplicate lookups of objects
with the same ID, but we'd still do one query per unique ID.

Now we allow columns to collect the data before rendering, based on the
objects being displayed. By default, this will loop through the objects,
build a list of all IDs that will be displayed, and then populate the
existing cache with those fetched objects. This reduces the query count
to at max one per column for all cases using ForeignKeys.

ManyToManyFields is another matter entirely, and will take more
specialized work.
Tested this with all the datagrids on my copy of Review Board. Everything
worked great. I verified through the list of SQL queries that we only
had one per column that used a ForeignKey. ManyToManyFields still caused
many more queries.

Unit tests also passed.
    Loading...