Merge ~pappacena/launchpad:oci-bug-indexes into launchpad:db-devel

Proposed by Thiago F. Pappacena
Status: Merged
Approved by: Colin Watson
Approved revision: 411d991a229f27aa0268faa53ca386c04a45ed6e
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~pappacena/launchpad:oci-bug-indexes
Merge into: launchpad:db-devel
Prerequisite: ~pappacena/launchpad:oci-bug-add-oci-columns
Diff against target: 141 lines (+135/-0)
1 file modified
database/schema/patch-2210-22-1.sql (+135/-0)
Reviewer Review Type Date Requested Status
William Grant db Approve
Colin Watson (community) db Approve
Review via email: mp+393579@code.launchpad.net

Commit message

Database indexes creation for OCI support on bug tracking system

To post a comment you must log in.
~pappacena/launchpad:oci-bug-indexes updated
e7a1ef0... by Thiago F. Pappacena

Merge branch 'oci-bug-add-oci-columns' into oci-bug-indexes

2511cb0... by Thiago F. Pappacena

Merge branch 'oci-bug-add-oci-columns' into oci-bug-indexes

f6fd54f... by Thiago F. Pappacena

Changing the index for BugTask(product, bug) to allow denormalization of product with ociproject

fa26e23... by Thiago F. Pappacena

Merge branch 'oci-bug-add-oci-columns' into oci-bug-indexes

Revision history for this message
Colin Watson (cjwatson) :
review: Needs Information (db)
Revision history for this message
Thiago F. Pappacena (pappacena) :
Revision history for this message
William Grant (wgrant) :
~pappacena/launchpad:oci-bug-indexes updated
24a5f15... by Thiago F. Pappacena

Merge branch 'oci-bug-add-oci-columns' into oci-bug-indexes

40a818c... by Thiago F. Pappacena

Moving misplaced index rename to another db patch

4f8b8d6... by Thiago F. Pappacena

Merge branch 'oci-bug-add-oci-columns' into oci-bug-indexes

Revision history for this message
Thiago F. Pappacena (pappacena) wrote :

Replied a couple of comments below.

~pappacena/launchpad:oci-bug-indexes updated
023de54... by Thiago F. Pappacena

Merge branch 'oci-bug-add-oci-columns' into oci-bug-indexes

9edfc1e... by Thiago F. Pappacena

Merge branch 'oci-bug-add-oci-columns' into oci-bug-indexes

Revision history for this message
Colin Watson (cjwatson) :
review: Approve (db)
Revision history for this message
William Grant (wgrant) :
review: Approve (db)
~pappacena/launchpad:oci-bug-indexes updated
411d991... by Thiago F. Pappacena

Fixing unique index names

Revision history for this message
Thiago F. Pappacena (pappacena) :
Revision history for this message
William Grant (wgrant) :
review: Approve (db)
Revision history for this message
Colin Watson (cjwatson) wrote :

Now applied to production, so landing this.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/database/schema/patch-2210-22-1.sql b/database/schema/patch-2210-22-1.sql
0new file mode 1006440new file mode 100644
index 0000000..7f4cedd
--- /dev/null
+++ b/database/schema/patch-2210-22-1.sql
@@ -0,0 +1,135 @@
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
6-- Validate check constraint.
7ALTER TABLE BugTask VALIDATE CONSTRAINT bugtask_assignment_checks;
8
9ALTER TABLE BugSummary VALIDATE CONSTRAINT bugtask_assignment_checks;
10
11-- BugTask indexes.
12CREATE UNIQUE INDEX bugtask__ociproject__bug__key
13 ON BugTask (ociproject, bug)
14 WHERE ociproject IS NOT NULL;
15CREATE UNIQUE INDEX bugtask__ociprojectseries__bug__key
16 ON BugTask (ociprojectseries, bug)
17 WHERE ociprojectseries IS NOT NULL;
18
19-- BugTaskFlat indexes.
20CREATE INDEX bugtaskflat__ociproject__bug__idx
21 ON BugTaskFlat (ociproject, bug)
22 WHERE ociproject IS NOT NULL;
23CREATE INDEX bugtaskflat__ociproject__date_closed__bug__idx
24 ON BugTaskFlat (ociproject, date_closed, bug DESC)
25 WHERE ociproject IS NOT NULL;
26CREATE INDEX bugtaskflat__ociproject__date_last_updated__idx
27 ON BugTaskFlat (ociproject, date_last_updated)
28 WHERE ociproject IS NOT NULL;
29CREATE INDEX bugtaskflat__ociproject__datecreated__idx
30 ON BugTaskFlat (ociproject, datecreated)
31 WHERE ociproject IS NOT NULL;
32CREATE INDEX bugtaskflat__ociproject__heat__bug__idx
33 ON BugTaskFlat (ociproject, heat, bug DESC)
34 WHERE ociproject IS NOT NULL;
35CREATE INDEX bugtaskflat__ociproject__importance__bug__idx
36 ON BugTaskFlat (ociproject, importance, bug DESC)
37 WHERE ociproject IS NOT NULL;
38CREATE INDEX bugtaskflat__ociproject__latest_patch_uploaded__bug__idx
39 ON BugTaskFlat (ociproject, latest_patch_uploaded, bug DESC)
40 WHERE ociproject IS NOT NULL;
41CREATE INDEX bugtaskflat__ociproject__status__bug__idx
42 ON BugTaskFlat (ociproject, status, bug DESC)
43 WHERE ociproject IS NOT NULL;
44
45CREATE INDEX bugtaskflat__ociprojectseries__bug__idx
46 ON BugTaskFlat (ociprojectseries, bug)
47 WHERE ociprojectseries IS NOT NULL;
48CREATE INDEX bugtaskflat__ociprojectseries__date_closed__bug__idx
49 ON BugTaskFlat (ociprojectseries, date_closed, bug DESC)
50 WHERE ociprojectseries IS NOT NULL;
51CREATE INDEX bugtaskflat__ociprojectseries__date_last_updated__idx
52 ON BugTaskFlat (ociprojectseries, date_last_updated)
53 WHERE ociprojectseries IS NOT NULL;
54CREATE INDEX bugtaskflat__ociprojectseries__datecreated__idx
55 ON BugTaskFlat (ociprojectseries, datecreated)
56 WHERE ociprojectseries IS NOT NULL;
57CREATE INDEX bugtaskflat__ociprojectseries__heat__bug__idx
58 ON BugTaskFlat (ociprojectseries, heat, bug DESC)
59 WHERE ociprojectseries IS NOT NULL;
60CREATE INDEX bugtaskflat__ociprojectseries__importance__bug__idx
61 ON BugTaskFlat (ociprojectseries, importance, bug DESC)
62 WHERE ociprojectseries IS NOT NULL;
63CREATE INDEX bugtaskflat__ociprojectseries__latest_patch_uploaded__bug__idx
64 ON BugTaskFlat (ociprojectseries, latest_patch_uploaded, bug DESC)
65 WHERE ociprojectseries IS NOT NULL;
66CREATE INDEX bugtaskflat__ociprojectseries__status__bug__idx
67 ON BugTaskFlat (ociprojectseries, status, bug DESC)
68 WHERE ociprojectseries IS NOT NULL;
69
70
71-- BugSummary indexes.
72CREATE INDEX bugsummary__ociproject__idx
73 ON BugSummary (ociproject)
74 WHERE ociproject IS NOT NULL;
75CREATE INDEX bugsummary__ociprojectseries__idx
76 ON BugSummary (ociprojectseries)
77 WHERE ociprojectseries IS NOT NULL;
78
79
80-- Replacing previously renamed indexes.
81CREATE UNIQUE INDEX bugtask_distinct_sourcepackage_assignment
82 ON BugTask (
83 bug,
84 COALESCE(sourcepackagename, -1),
85 COALESCE(distroseries, -1),
86 COALESCE(distribution, -1)
87 )
88 WHERE
89 product IS NULL
90 AND productseries IS NULL
91 AND ociproject IS NULL
92 AND ociprojectseries IS NULL;
93DROP INDEX old__bugtask_distinct_sourcepackage_assignment;
94
95
96CREATE UNIQUE INDEX bugtask__product__bug__key
97 ON BugTask (product, bug)
98 WHERE
99 product IS NOT NULL
100 AND ociproject IS NULL
101 AND ociprojectseries IS NULL;
102DROP INDEX old__bugtask__product__bug__key;
103
104
105CREATE UNIQUE INDEX bugsummary__unique
106 ON BugSummary (
107 COALESCE(product, -1),
108 COALESCE(productseries, -1),
109 COALESCE(distribution, -1),
110 COALESCE(distroseries, -1),
111 COALESCE(sourcepackagename, -1),
112 COALESCE(ociproject, -1),
113 COALESCE(ociprojectseries, -1),
114 status,
115 importance,
116 has_patch,
117 COALESCE(tag, ''::text),
118 COALESCE(milestone, -1),
119 COALESCE(viewed_by, -1),
120 COALESCE(access_policy, -1)
121 );
122DROP INDEX old__bugsummary__unique;
123
124
125CREATE INDEX bugsummaryjournal__full__idx
126 ON BugSummaryJournal (
127 status, product, productseries, distribution, distroseries,
128 sourcepackagename, ociproject, ociprojectseries, viewed_by, milestone,
129 tag
130 );
131
132DROP INDEX old__bugsummaryjournal__full__idx;
133
134
135INSERT INTO LaunchpadDatabaseRevision VALUES (2210, 22, 1);