Comment 5 for bug 787294

Revision history for this message
Robert Collins (lifeless) wrote : Re: Person:+patches timeouts

This query completes in 7.7 seconds (not great, but better):
SELECT distinct BugTask.id FROM BugTask inner join bug on bug.id=bugtask.bug LEFT JOIN Product ON BugTask.product = Product.id AND Product.active inner join structuralsubscription ss on (
ss.subscriber = 343381
 and
         BugTask.product is NULL = ss.product
         OR BugTask.productseries = ss.productseries
         OR Product.project = ss.project
         AND BugTask.product = Product.id
         OR BugTask.distribution = ss.distribution
         AND (BugTask.sourcepackagename = ss.sourcepackagename
              OR ss.sourcepackagename IS NULL)
         OR BugTask.distroseries = ss.distroseries
         OR BugTask.milestone = ss.milestone
)
         WHERE ((BugTask.status = 10) OR (BugTask.status = 15) OR (BugTask.status = 20) OR (BugTask.status = 21) OR (BugTask.status = 22) OR (BugTask.status = 25))
           AND Bug.duplicateof IS NULL
           AND Bug.latest_patch_uploaded IS NOT NULL
           AND Bug.private = FALSE;

key changes: remove redundant product.active check - the constrained left join takes care of that. However, I suspect the join is buggy (= and NULL handling)