Use select_related to reduce SQL queries in resource API methods

Review Request #1894 — Created Nov. 6, 2010 and submitted — Latest diff uploaded




This change uses select_related ( to reduce the number of queries needed to serve resources. Select_related will use joins to include one-to-one relations in the initial query, meaning you won't have to do another query to fetch them after the main object is retrieved. Since the API methods always return the completely expanded object, this can end up being a significant savings in queries with no real downside since there aren't situations where those records wouldn't have been retrieved anyway.

This change is on this branch in GitHub:
I turned on SQL logging on my copy of ReviewBoard and verified that this change reduces the number of SQL queries performed to serve API requests.