Merge ~cjwatson/launchpad:db-split-bpph-creator-index into launchpad:db-devel

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: b85c45e2fc6802d4be22ef3cadd0fc3e0eb9ab85
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:db-split-bpph-creator-index
Merge into: launchpad:db-devel
Diff against target: 34 lines (+9/-4)
2 files modified
database/schema/patch-2210-11-1.sql (+0/-4)
database/schema/patch-2210-11-2.sql (+9/-0)
Reviewer Review Type Date Requested Status
William Grant db Approve
Review via email: mp+380770@code.launchpad.net

Commit message

Split BPPH(creator) index into a separate DB patch

This works because the index is only needed in a few places (person
merging, team visibility changes, closing accounts, and PersonPruner in
garbo), so if it's absent for a short time while the index is created
with CONCURRENTLY then nothing goes too badly wrong.

Changing an already-committed patch shouldn't be taken as precedent. We
can get away with it in this case, but we'll need to fix things up
manually on staging.

Description of the change

On production, the index will have to be created separately with CONCURRENTLY, since BinaryPackagePublishingHistory is a large table.

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) wrote :

Do note in the commit message that this is highly evil and not precedent. But otherwise looks good.

review: Approve (db)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/database/schema/patch-2210-11-1.sql b/database/schema/patch-2210-11-1.sql
index 9791451..57e77e9 100644
--- a/database/schema/patch-2210-11-1.sql
+++ b/database/schema/patch-2210-11-1.sql
@@ -7,9 +7,6 @@ SET client_min_messages=ERROR;
7ALTER TABLE binarypackagepublishinghistory7ALTER TABLE binarypackagepublishinghistory
8 ADD COLUMN creator INTEGER REFERENCES person;8 ADD COLUMN creator INTEGER REFERENCES person;
99
10CREATE INDEX binarypackagepublishinghistory__creator__idx ON
11 binarypackagepublishinghistory(creator) WHERE creator IS NOT NULL;
12
1310
14ALTER TABLE binarypackagepublishinghistory11ALTER TABLE binarypackagepublishinghistory
15 ADD COLUMN copied_from_archive INTEGER REFERENCES archive;12 ADD COLUMN copied_from_archive INTEGER REFERENCES archive;
@@ -20,4 +17,3 @@ ALTER TABLE sourcepackagepublishinghistory
2017
2118
22INSERT INTO LaunchpadDatabaseRevision VALUES (2210, 11, 1);19INSERT INTO LaunchpadDatabaseRevision VALUES (2210, 11, 1);
23
diff --git a/database/schema/patch-2210-11-2.sql b/database/schema/patch-2210-11-2.sql
24new file mode 10064420new file mode 100644
index 0000000..0fc12bc
--- /dev/null
+++ b/database/schema/patch-2210-11-2.sql
@@ -0,0 +1,9 @@
1-- Copyright 2020 Canonical Ltd. This software is licensed under the
2-- GNU Affero General Public License version 3 (see the file LICENSE).
3
4SET client_min_messages=ERROR;
5
6CREATE INDEX binarypackagepublishinghistory__creator__idx ON
7 binarypackagepublishinghistory(creator) WHERE creator IS NOT NULL;
8
9INSERT INTO LaunchpadDatabaseRevision VALUES (2210, 11, 2);

Subscribers

People subscribed via source and target branches

to status/vote changes: