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

Proposed by Colin Watson
Status: Superseded
Proposed branch: ~cjwatson/launchpad:db-archive-file-date-indexes
Merge into: launchpad:db-devel
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 Needs Information
Review via email: mp+435292@code.launchpad.net

This proposal has been superseded by a proposal from 2023-02-01.

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 :

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 :

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

Unmerged commits

38297b3... by Colin Watson

Add ArchiveFile.{date_created,date_superseded} indexes

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

LP: #1765933

Succeeded
[SUCCEEDED] docs:0 (build)
[SUCCEEDED] lint:0 (build)
[SUCCEEDED] mypy:0 (build)
13 of 3 results

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: