Merge lp:~wgrant/launchpad/bpn-spn-trgm-index into lp:launchpad

Proposed by William Grant
Status: Merged
Merged at revision: 15917
Proposed branch: lp:~wgrant/launchpad/bpn-spn-trgm-index
Merge into: lp:launchpad
Diff against target: 15 lines (+11/-0)
1 file modified
database/schema/patch-2209-23-1.sql (+11/-0)
To merge this branch: bzr merge lp:~wgrant/launchpad/bpn-spn-trgm-index
Reviewer Review Type Date Requested Status
Stuart Bishop (community) db Approve
Review via email: mp+123208@code.launchpad.net

Commit message

Add trigram indices on BinaryPackageName and SourcePackageName, to satisfy %foo% matches.

Description of the change

My trigram index experiment on the sacrificial DistributionSourcePackageCache table worked fine, so let's expand it to SourcePackageName and BinaryPackageName. This is mostly to optimise the exact_match=False variants of getPublishedSources and getPublishedBinaries, taking a problematic example from ~200ms to 10ms.

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

Looks good.

We probably want to use __trgm as the index name suffix to avoid colliding with our existing crappy naming conventions.

review: Approve (db)
Revision history for this message
Stuart Bishop (stub) wrote :

Applied to production

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-1.sql'
2--- database/schema/patch-2209-23-1.sql 1970-01-01 00:00:00 +0000
3+++ database/schema/patch-2209-23-1.sql 2012-09-07 04:34:22 +0000
4@@ -0,0 +1,11 @@
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 binarypackagename__name__trgm ON binarypackagename
11+ USING gin (name trgm.gin_trgm_ops);
12+CREATE INDEX sourcepackagename__name__trgm ON sourcepackagename
13+ USING gin (name trgm.gin_trgm_ops);
14+
15+INSERT INTO LaunchpadDatabaseRevision VALUES (2209, 23, 1);