Bug 7270 - Make django use a single query on queries using foreign key
Summary: Make django use a single query on queries using foreign key
Status: RESOLVED FIXED
Alias: None
Product: Toaster
Classification: Build System, Metadata & Runtime
Component: toaster (show other bugs)
Version: unspecified
Hardware: x86 Multiple
: Medium enhancement
Target Milestone: Future
Assignee: Alexandru Damian
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2015-01-30 15:39 UTC by Michael Wood
Modified: 2015-04-30 14:35 UTC (History)
5 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: No (bug/feature does not impact docs)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Wood 2015-01-30 15:39:40 UTC
When we're querying the db and we want to access items from their foreign key e.g. Layer_Version.Layer if we use 'select_related' which tells django that we're going to need the items in the foreign table then it's able to do a inner join instead of running a lookup query for each item.

https://docs.djangoproject.com/en/1.7/ref/models/querysets/#select-related

I implemented this in the error-report-web and it's a big performance win when returning larger data sets
Comment 1 Alexandru Damian 2015-02-17 18:01:03 UTC
partially implemented in adamian/20150217_bug_7004 because of annoying issues when refreshing.
Comment 2 Alexandru Damian 2015-04-30 14:35:04 UTC
All identified performance bottlenecks due to multiple linked requests have been changed to select_related, or batched array-based selection, and patches merged.