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)
This query completes in 7.7 seconds (not great, but better): ription ss on (
BugTask. product is NULL = ss.product productseries = ss.productseries distribution = ss.distribution sourcepackagena me = ss.sourcepackag ename ename IS NULL) distroseries = ss.distroseries patch_uploaded IS NOT NULL
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 structuralsubsc
ss.subscriber = 343381
and
OR BugTask.
OR Product.project = ss.project
AND BugTask.product = Product.id
OR BugTask.
AND (BugTask.
OR ss.sourcepackag
OR BugTask.
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_
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)