Comment 4 for bug 904339

Revision history for this message
Curtis Hovey (sinzui) wrote : Re: timeout querying a list of bugs ordered by heat on packages a team is subscribed to

This is the long query from the most recent oops at 8920.0ms:

WITH ss AS (
SELECT *
FROM StructuralSubscription
WHERE StructuralSubscription.subscriber = $INT)
  SELECT BugTaskFlat.bugtask
  FROM BugTaskFlat WHERE BugTaskFlat.bugtask IN (
  SELECT BugTaskFlat.bugtask
  FROM BugTaskFlat
  LEFT JOIN Product ON BugTaskFlat.product = Product.id
  AND Product.active
  LEFT JOIN ss AS "_23f0" ON BugTaskFlat.product = "_23f0".product
  LEFT JOIN ss AS "_23f1" ON BugTaskFlat.productseries = "_23f1".productseries
  LEFT JOIN ss AS "_23f2" ON Product.project = "_23f2".project
  LEFT JOIN ss AS "_23f3" ON BugTaskFlat.distribution = "_23f3".distribution
  AND ("_23f3".sourcepackagename = BugTaskFlat.sourcepackagename
       OR "_23f3".sourcepackagename IS NULL)
  LEFT JOIN ss AS "_23f4" ON BugTaskFlat.distroseries = "_23f4".distroseries
  OR "_23f4".distribution = $INT
  AND BugTaskFlat.sourcepackagename = "_23f4".sourcepackagename
  LEFT JOIN ss AS "_23f5" ON BugTaskFlat.milestone = "_23f5".milestone WHERE BugTaskFlat.distribution = $INT
  AND BugTaskFlat.status IN ($INT ... $INT)
  AND BugTaskFlat.duplicateof IS NULL
  AND NULL_COUNT(ARRAY["_23f0".id, "_23f1".id, "_23f2".id, "_23f3".id, "_23f4".id, "_23f5".id]) < $INT
  AND (BugTaskFlat.information_type IN ($INT, $INT)
  OR COALESCE((BugTaskFlat.access_grants)&&
                (SELECT ARRAY_AGG(TeamParticipation.team)
                 FROM TeamParticipation
                 WHERE TeamParticipation.person = $INT), FALSE)
              OR COALESCE((BugTaskFlat.access_policies)&&
                            (SELECT ARRAY_AGG(AccessPolicyGrant.policy)
                             FROM AccessPolicyGrant
                             JOIN TeamParticipation ON TeamParticipation.team = AccessPolicyGrant.grantee
                             WHERE TeamParticipation.person = $INT), FALSE)))
ORDER BY BugTaskFlat.heat DESC, BugTaskFlat.bugtask LIMIT $INT
OFFSET $INT