Revision karma allocator glacial and needed to be disabled
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Launchpad itself |
Fix Released
|
Undecided
|
Stuart Bishop |
Bug Description
The following query no longer performs adequately under PostgreSQL 8.4:
SELECT Revision.*
FROM Revision, RevisionAuthor, ValidPersonCache
WHERE
Revision.
AND RevisionAuthor.
AND NOT Revision.
AND EXISTS (
SELECT true FROM Branch, BranchRevision
WHERE BranchRevision.
AND BranchRevision.
AND (
NOT (Branch.product IS NULL)
OR NOT (Branch.
LIMIT 100 OFFSET 0;
The simplest fix is to add a LIMIT into the EXISTS subquery, which I think restores the 8.3 behavior we were relying on:
SELECT Revision.*
FROM Revision, RevisionAuthor, ValidPersonCache
WHERE
Revision.
AND RevisionAuthor.
AND NOT Revision.
AND EXISTS (
SELECT true FROM Branch, BranchRevision
WHERE BranchRevision.
AND BranchRevision.
AND (
NOT (Branch.product IS NULL)
OR NOT (Branch.
LIMIT 1)
LIMIT 100 OFFSET 0;
A better fix is to return up to 100 rows instead of exactly 100 rows, which can be performed 10x faster:
SELECT DISTINCT * FROM (
SELECT Revision.*
FROM Revision, RevisionAuthor, ValidPersonCache, Branch, BranchRevision
WHERE
Revision.
AND RevisionAuthor.
AND NOT Revision.
AND BranchRevision.
AND BranchRevision.
AND (NOT (Branch.product IS NULL) OR NOT (Branch.
LIMIT 100) AS Whatever;
Related branches
- Tim Penhey (community): Approve
- Robert Collins (community): Approve (release-critical)
-
Diff: 83 lines (+13/-14)3 files modifiedlib/lp/code/interfaces/revision.py (+1/-1)
lib/lp/code/model/revision.py (+11/-12)
lib/lp/code/scripts/revisionkarma.py (+1/-1)
Changed in launchpad-code: | |
status: | Fix Committed → Fix Released |
The branch karma allocator has been disabled on production as it is just wasting DB resources and is unlikely to ever actually complete.