Merge ~cjwatson/launchpad:db-archive-file-date-indexes into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 1c590df1a71e6b77741d71732777cc1d054de502
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:db-archive-file-date-indexes
Merge into: launchpad:master
Diff against target: 22 lines (+16/-0)
1 file modified
database/schema/patch-2211-15-0.sql (+16/-0)
Reviewer Review Type Date Requested Status
William Grant db Approve
Review via email: mp+436681@code.launchpad.net

This proposal supersedes a proposal from 2023-01-06.

Commit message

Add ArchiveFile.{date_created,date_superseded} indexes

Description of the change

These allow efficient queries of the state of a path at a given time, and ensure that only one file holds a given path.

Following up on https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/373970 from long ago now that the associated code has finally landed.

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

Should this be applied hot instead? Also a couple of other comments.

review: Needs Information (db)
Revision history for this message
Colin Watson (cjwatson) wrote : Posted in a previous version of this proposal

Er yes, this should indeed be hot. I'll re-propose this against master.

Revision history for this message
William Grant (wgrant) :
review: Approve (db)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/database/schema/patch-2211-15-0.sql b/database/schema/patch-2211-15-0.sql
2new file mode 100644
3index 0000000..730b566
4--- /dev/null
5+++ b/database/schema/patch-2211-15-0.sql
6@@ -0,0 +1,16 @@
7+-- Copyright 2023 Canonical Ltd. This software is licensed under the
8+-- GNU Affero General Public License version 3 (see the file LICENSE).
9+
10+SET client_min_messages=ERROR;
11+
12+-- Allow efficient queries of the state of a path at a given time.
13+CREATE INDEX archivefile__archive__date_created__date_superseded__path__idx
14+ ON ArchiveFile (archive, date_created, date_superseded, path)
15+ WHERE date_created IS NOT NULL;
16+
17+-- Only one file may hold a given path at once.
18+CREATE UNIQUE INDEX archivefile__archive__path__date_superseded__key
19+ ON ArchiveFile (archive, path)
20+ WHERE date_superseded IS NULL;
21+
22+INSERT INTO LaunchpadDatabaseRevision VALUES (2211, 15, 0);

Subscribers

People subscribed via source and target branches

to status/vote changes: