Bug 7270

Summary: Make django use a single query on queries using foreign key
Product: [Build System, Metadata & Runtime] Toaster Reporter: Michael Wood <michael.g.wood>
Component: toasterAssignee: Alexandru Damian <alexandru.damian>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: Medium CC: alexandru.damian, belen.barros.pena, bluelightning, cristiana.voicu, jessica.zhang
Version: unspecified   
Target Milestone: Future   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)

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.