Bulk project access checks are slow

Bug #1425430 reported by William Grant
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Launchpad itself
Fix Released
Critical
William Grant

Bug Description

ProductSet.getProductPrivacyFilter does a four table join to identify accessible private projects, causing the subquery to regularly take 300ms for participants of teams like ~registry or ~pmteam. This can cause project searches or the top contributions list on Person:+index to time out like OOPS-45decddcd5032cacc973f3616ac66506.

If we follow the denormalisation pattern from Branch and Bug by creating Product.access_policies, and index TeamParticipation(person, team) and AccessPolicyGrantFlat(grantee, policy) it can be made a little faster:

-- Old: 280000 pages, 362ms.
EXPLAIN (ANALYZE ON, BUFFERS ON)
SELECT DISTINCT Product.id
FROM AccessPolicy,
    AccessPolicyGrantFlat,
    Product,
    TeamParticipation
WHERE
    AccessPolicyGrantFlat.grantee = TeamParticipation.team
    AND TeamParticipation.person = 21997
    AND AccessPolicyGrantFlat.policy = AccessPolicy.id
    AND AccessPolicy.product = Product.id
    AND AccessPolicy.TYPE = Product.information_type;

-- New: 874 pages, 34ms.
EXPLAIN (ANALYZE ON, BUFFERS ON)
SELECT DISTINCT AccessPolicyGrantFlat.policy
FROM AccessPolicyGrantFlat, TeamParticipation
WHERE
    AccessPolicyGrantFlat.grantee = TeamParticipation.team
    AND TeamParticipation.person = 1425512;

Related branches

William Grant (wgrant)
Changed in launchpad:
assignee: nobody → William Grant (wgrant)
status: Triaged → In Progress
Revision history for this message
Launchpad QA Bot (lpqabot) wrote :
tags: added: qa-needstesting
Changed in launchpad:
status: In Progress → Fix Committed
William Grant (wgrant)
tags: added: qa-ok
removed: qa-needstesting
William Grant (wgrant)
Changed in launchpad:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.