Merge lp:~danilo/launchpad/bug-662552-fast-pofile-selection into lp:launchpad
Status: | Merged |
---|---|
Approved by: | Gavin Panella |
Approved revision: | no longer in the source branch. |
Merged at revision: | 11911 |
Proposed branch: | lp:~danilo/launchpad/bug-662552-fast-pofile-selection |
Merge into: | lp:launchpad |
Diff against target: |
88 lines (+47/-13) 2 files modified
lib/lp/translations/model/translationmessage.py (+17/-13) lib/lp/translations/tests/test_translationmessage.py (+30/-0) |
To merge this branch: | bzr merge lp:~danilo/launchpad/bug-662552-fast-pofile-selection |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Gavin Panella (community) | Approve | ||
Review via email: mp+40615@code.launchpad.net |
Commit message
[r=allenap]
Description of the change
= Bug 662552 =
After 8.4 migration, a specific query has become much slower and that's causing a big number of timeouts on POFile:+translate page (the most important page in Translations). Proper solution would be to refactor the entire page and views to not emit hundreds of queries, but that's more work that we'll have to do over time.
For now, we first worked around the problem by disabling global suggestions, one of very useful features in Translations. That bought us some time to fix the problem (before users start complaining about global suggestions not showing up).
And this branch is now, hopefully, fix for the problem. We'll see how much it helps when it gets rolled out to production (I'll cowboy it on staging as soon as a LOSA shows up to test it out), but it does a few what might seem to be nasty things.
1. It uses a subselect for what would otherwise be a very straightforward join query
2. It uses LIMIT in the subselect, so we can't use Storm syntax for the subselect (afaik)
3. It's not equivalent query to the previous one, but my knowledge of the data model allows me to optimize it better (i.e. restrict more before the join)
getOnePOFile does not return a predictable result. The point is that it needs to return one POFile where TranslationMessage is used, and it doesn't really matter which one it is.
I've also added a few unit tests since this method was not tested so far.
= Tests =
bin/test -cvvt getOnePOFile
= Launchpad lint =
Checking for conflicts and issues in changed files.
Linting changed files:
lib/lp/
lib/lp/
Looks good, especially if it's 100 times faster!
If you want to use Storm syntax, it may work just as well to use an IN
query:
SELECT POFile.* lateItem
FROM POFile
WHERE POFile.potemplate IN (
SELECT potemplate
FROM TranslationTemp
WHERE potmsgset = 1
AND sequence > 0)
LIMIT 1;
If PostgreSQL is sensible it will optimize that. But, to be honest, if
what you've got works, use it and ignore me :)