Reduce the query count by one per page when using SiteConfiguration.

Review Request #4808 — Created Oct. 20, 2013 and submitted

Information

Djblets
master

Reviewers

Reduce the query count by one per page when using SiteConfiguration.

SiteConfiguration always looked up self.site to build the cache key,
which did a query for the proper Site. However, in every realistic case,
that's going to be equal to Site.objects.get_current(), which either
will have been fetched at that point, or soon would be anyway.

We now fetch this and, if it's the ID we expect, we set the current
instance to it. That reduces an unnecessary query per request.

Checked the listed queries before and after this change. The count
went down by one.

Unit tests pass.

david
  1. Ship It!

  2. 
      
chipx86
Review request changed

Status: Closed (submitted)

Loading...