Bulk project access checks are slow

Bug #1425430 reported by William Grant on 2015-02-25
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Launchpad itself
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) on 2015-06-30
Changed in launchpad:
assignee: nobody → William Grant (wgrant)
status: Triaged → In Progress
Launchpad QA Bot (lpqabot) wrote :
tags: added: qa-needstesting
Changed in launchpad:
status: In Progress → Fix Committed
William Grant (wgrant) on 2015-07-02
tags: added: qa-ok
removed: qa-needstesting
William Grant (wgrant) on 2015-07-02
Changed in launchpad:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers