Merge lp:~wgrant/launchpad/bugsummary-v2-db-1 into lp:launchpad

Proposed by William Grant
Status: Merged
Approved by: Stuart Bishop
Approved revision: no longer in the source branch.
Merged at revision: 15605
Proposed branch: lp:~wgrant/launchpad/bugsummary-v2-db-1
Merge into: lp:launchpad
Prerequisite: lp:launchpad/db-devel
Diff against target: 30 lines (+26/-0)
1 file modified
database/schema/patch-2209-19-1.sql (+26/-0)
To merge this branch: bzr merge lp:~wgrant/launchpad/bugsummary-v2-db-1
Reviewer Review Type Date Requested Status
Stuart Bishop (community) db Approve
Review via email: mp+113500@code.launchpad.net

Commit message

Create some new indices on bugsummary, optimising rebuilds and coping with the new access_policy and deprecated fixed_upstream columns.

Description of the change

The main BugSummary queries come in two forms: finding all visible rows for a target without a tag, or finding all visible rows for a target with a tag. The product and productseries indices work well for this, but distribution, distroseries, distributionsourcepackage and sourcepackage queries always search on (distribution, sourcepackagename), which was not previously indexed. This branch adds four new indices to satisfy the tagged and tagless queries for all four target types, and another two indices to optimise bugsummaryrebuild's queries which don't filter on tag nullness.

Several of the old indices will be dropped at the conclusion of this work, and a new UNIQUE index will be created in the next branch.

This should be applied live shortly after 2209-19-0 is fastdowntimed.

To post a comment you must log in.
Revision history for this message
Stuart Bishop (stub) wrote :

Looks fine.

I assume all the _idx2 names are going to be renamed after other indexes are dropped.

It might be helpful for us to have a test helper that does "SET enable_seqscan=off; EXPLAIN (FORMAT JSON) $query;" and checks the result to make sure a particular index is being hit.

review: Approve (db)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'database/schema/patch-2209-19-1.sql'
2--- database/schema/patch-2209-19-1.sql 1970-01-01 00:00:00 +0000
3+++ database/schema/patch-2209-19-1.sql 2012-07-05 07:15:27 +0000
4@@ -0,0 +1,26 @@
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 INDEX bugsummary__distribution__idx2 ON bugsummary USING btree
11+ (distribution, sourcepackagename) WHERE distribution IS NOT NULL;
12+CREATE INDEX bugsummary__distroseries__idx2 ON bugsummary USING btree
13+ (distroseries, sourcepackagename) WHERE distroseries IS NOT NULL;
14+CREATE INDEX bugsummary__distribution_count__idx2 ON bugsummary USING btree
15+ (distribution, sourcepackagename, status)
16+ WHERE distribution IS NOT NULL AND tag IS NULL;
17+CREATE INDEX bugsummary__distroseries_count__idx2 ON bugsummary USING btree
18+ (distroseries, sourcepackagename, status)
19+ WHERE distroseries IS NOT NULL AND tag IS NULL;
20+CREATE INDEX bugsummary__distribution_tag_count__idx2 ON bugsummary USING btree
21+ (distribution, sourcepackagename, status)
22+ WHERE distribution IS NOT NULL AND tag IS NOT NULL;
23+CREATE INDEX bugsummary__distroseries_tag_count__idx2 ON bugsummary USING btree
24+ (distroseries, sourcepackagename, status)
25+ WHERE distroseries IS NOT NULL AND tag IS NOT NULL;
26+CREATE INDEX bugsummary__full__idx2 ON bugsummary USING btree
27+ (tag, status, product, productseries, distribution, distroseries,
28+ sourcepackagename, viewed_by, access_policy, milestone, importance);
29+
30+INSERT INTO LaunchpadDatabaseRevision VALUES (2209, 19, 1);