Actually, it might be triggered by 8.4. The following query performs well enough:
SELECT BugTask.*, Product.*, SourcePackageName.*, Bug.*
FROM BugTask
JOIN Bug ON BugTask.bug = Bug.id
LEFT JOIN Product ON BugTask.product = Product.id
LEFT JOIN SourcePackageName ON BugTask.sourcepackagename = SourcePackageName.id WHERE
BugTask.status IN (10, 15, 20, 21, 22, 25)
AND Bug.duplicateof is NULL
AND Bug.private IS FALSE
AND BugTask.id IN (
SELECT DISTINCT BugTask.id
FROM BugTask, BugMessage, Message
WHERE Message.owner = 293289
AND Message.id = BugMessage.message
AND BugTask.bug = BugMessage.bug
AND Message.id NOT IN ( SELECT BugMessage.message FROM BugMessage WHERE BugMessage.bug = BugTask.bug ORDER BY BugMessage.id LIMIT 1 ) )
ORDER BY BugTask.importance DESC, BugTask.id LIMIT 76 OFFSET 0;
The differences here:
- Use a normal join for Bug rather than a left outer join.
- Add DISTINCT to the first IN subselect. Ideally the query planner would do this for us in cases where it helps and not hinders.
Actually, it might be triggered by 8.4. The following query performs well enough:
SELECT BugTask.*, Product.*, SourcePackageNa me.*, Bug.* sourcepackagena me = SourcePackageNa me.id WHERE
Message. owner = 293289
SELECT BugMessage.message FROM BugMessage
WHERE BugMessage.bug = BugTask.bug
ORDER BY BugMessage.id LIMIT 1 ) )
FROM BugTask
JOIN Bug ON BugTask.bug = Bug.id
LEFT JOIN Product ON BugTask.product = Product.id
LEFT JOIN SourcePackageName ON BugTask.
BugTask.status IN (10, 15, 20, 21, 22, 25)
AND Bug.duplicateof is NULL
AND Bug.private IS FALSE
AND BugTask.id IN (
SELECT DISTINCT BugTask.id
FROM BugTask, BugMessage, Message
WHERE
AND Message.id = BugMessage.message
AND BugTask.bug = BugMessage.bug
AND Message.id NOT IN (
ORDER BY BugTask.importance DESC, BugTask.id LIMIT 76 OFFSET 0;
The differences here:
- Use a normal join for Bug rather than a left outer join.
- Add DISTINCT to the first IN subselect. Ideally the query planner would do this for us in cases where it helps and not hinders.