Merge lp:~wgrant/launchpad/i-am-stupid into lp:launchpad

Proposed by William Grant on 2012-09-10
Status: Merged
Approved by: Stuart Bishop on 2012-09-10
Approved revision: no longer in the source branch.
Merged at revision: 15927
Proposed branch: lp:~wgrant/launchpad/i-am-stupid
Merge into: lp:launchpad
Diff against target: 20 lines (+16/-0)
1 file modified
database/schema/patch-2209-23-2.sql (+16/-0)
To merge this branch: bzr merge lp:~wgrant/launchpad/i-am-stupid
Reviewer Review Type Date Requested Status
Stuart Bishop db 2012-09-10 Approve on 2012-09-10
Robert Collins db 2012-09-10 Pending
Review via email: mp+123478@code.launchpad.net

Commit Message

Add a few missing indices on AccessArtifactGrant and AccessPolicyGrant. Most notably on AccessPolicyGrant(grantee, policy), to accelerate person->APG lookups.

Description of the Change

Add a few missing indices on AccessArtifactGrant and AccessPolicyGrant. Most notably on AccessPolicyGrant(grantee, policy), to accelerate person->APG lookups.

This fixes the performance of a lot of branch and bug permission checks, as they'll no longer have to do a sequential scan on AccessPolicyGrant to determine a person's granted policies.

To post a comment you must log in.
Stuart Bishop (stub) wrote :

All looks fine.

review: Approve (db)
Stuart Bishop (stub) wrote :

We decided making the compound indexes UNIQUE is worthwile

Stuart Bishop (stub) wrote :

Applied to production and qastaging

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'database/schema/patch-2209-23-2.sql'
2--- database/schema/patch-2209-23-2.sql 1970-01-01 00:00:00 +0000
3+++ database/schema/patch-2209-23-2.sql 2012-09-10 10:10:27 +0000
4@@ -0,0 +1,16 @@
5+-- Copyright 2012 Canonical Ltd. This software is licensed under the
6+-- GNU Affero General Public License version 3 (see the file LICENSE).
7+
8+SET client_min_messages=ERROR;
9+
10+CREATE UNIQUE INDEX accesspolicygrant__grantee__policy__key
11+ ON accesspolicygrant (grantee, policy);
12+CREATE INDEX accesspolicygrant__grantor__idx
13+ ON accesspolicygrant (grantor);
14+
15+CREATE UNIQUE INDEX accessartifactgrant__grantee__artifact__key
16+ ON accessartifactgrant (grantee, artifact);
17+CREATE INDEX accessartifactgrant__grantor__idx
18+ ON accessartifactgrant (grantor);
19+
20+INSERT INTO LaunchpadDatabaseRevision VALUES (2209, 23, 2);