Merge lp:~lifeless/launchpad/bug-618849 into lp:launchpad
Status: | Merged |
---|---|
Approved by: | Michael Hudson-Doyle |
Approved revision: | no longer in the source branch. |
Merged at revision: | 11472 |
Proposed branch: | lp:~lifeless/launchpad/bug-618849 |
Merge into: | lp:launchpad |
Diff against target: |
388 lines (+144/-27) 11 files modified
lib/canonical/launchpad/database/message.py (+1/-1) lib/lp/bugs/browser/bug.py (+8/-6) lib/lp/bugs/browser/bugtask.py (+1/-1) lib/lp/bugs/browser/tests/bugtarget-filebug-views.txt (+1/-1) lib/lp/bugs/configure.zcml (+1/-0) lib/lp/bugs/doc/bug.txt (+6/-2) lib/lp/bugs/interfaces/bug.py (+10/-0) lib/lp/bugs/model/bug.py (+50/-9) lib/lp/bugs/model/bugattachment.py (+13/-2) lib/lp/bugs/tests/test_bugs_webservice.py (+52/-4) lib/lp/testing/sampledata.py (+1/-1) |
To merge this branch: | bzr merge lp:~lifeless/launchpad/bug-618849 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Michael Hudson-Doyle | Approve | ||
Jelmer Vernooij | Pending | ||
Review via email: mp+34011@code.launchpad.net |
Commit message
Remove O(N^2) scaling from the Bug.attachments API call by injecting IIndexedMessage objects into the BugAttachments.
Description of the change
Reduce the query count for bug/attachments API calls: inject an IIndexedMessage into the bug attachment when we query, rather than doing O(N^2) work later. Also, to make my test easier to write, fixed up the LibraryFileAlias lookups to be eager loaded.
Net result - 23 SQL calls to answer the API (down from 38 for a bug with 2 attachments when I started testing this). There is a lurking surprise when indexed_messages becomes too expensive to query; I think we probably want the index in the DB rather than calculating at runtime, however that is a separate bridge to cross in the future.
The implementation is a little convoluted due to:
- needing to index a *non db class* as the answer for bugattachment.
- lazr.restful not being able to replace an unexported attribute. (bug 625102)
The former point is also potentially solvable via lazr restful, but I'm not sure its a bug, so its just a question for now.
I've done some driveby cleanups to sample data in the test I modified too.
As we discussed on IRC, I'm fine with all the code, but asked for a few changes in the docs.