BugTask:+distrotask timeout on HEAT lookup
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Launchpad itself |
Fix Released
|
High
|
Graham Binns |
Bug Description
https:/
Branch: launchpad-rev-11315
Revno: 11315
SQL time: 14211 ms
Non-sql time: 103 ms
Total time: 14314 ms
Statement Count: 30
https:/
26. 295 14007ms launchpad-
is the cuplrit here.
lpmain_staging=> explain analyze SELECT Bug.heat FROM Bug, Bugtask, DistroSeries WHERE Bugtask.bug = Bug.id AND Bugtask.
-------
Limit (cost=2.38..1413.68 rows=1 width=4) (actual time=12091.
-> Nested Loop (cost=2.
Join Filter: (bugtask.
-> Nested Loop (cost=0.
-> Index Scan Backward using bug__heat__idx on bug (cost=0.
-> Index Scan using bugtask__bug__idx on bugtask (cost=0.00..0.48 rows=1 width=8) (actual time=0.006..0.007 rows=1 loops=607701)
-> Materialize (cost=2.38..2.39 rows=1 width=4) (actual time=0.001..0.003 rows=4 loops=709308)
-> Seq Scan on distroseries (cost=0.00..2.38 rows=1 width=4) (actual time=0.017..0.033 rows=4 loops=1)
Total runtime: 12091.312 ms
Related branches
- Julian Edwards (community): Approve (release-critical)
- Robert Collins (community): Approve
- Launchpad code reviewers: Pending (code) requested
-
Diff: 41 lines (+8/-12)1 file modifiedlib/lp/bugs/model/bugtarget.py (+8/-12)
Changed in malone: | |
status: | Triaged → In Progress |
assignee: | nobody → Graham Binns (gmb) |
milestone: | none → 10.08 |
Changed in malone: | |
status: | Fix Committed → Fix Released |
This rewritten query runs in 60ms on production:
SELECT max(Bug.heat) FROM Bug, BugTask, DistroSeries distroseries = DistroSeries.id distribution= 3;
WHERE BugTask.bug = Bug.id
AND BugTask.
AND DistroSeries.
I can't really explain why PG is choosing such an appalling query plan for the current query. I suspect it to do with ORDER BY Bug.heat DESC LIMIT 1 not quite being identical to MAX(Bug.heat) - the first will return NULL if there are any NULL Bug.heat due to the default ordering of NULL values. We are smart enough to know there is a NOT NULL constraint on that column, but PG 8.3 might not be.