Merge ~wgrant/launchpad:bprdc-ios into launchpad:master

Proposed by William Grant
Status: Merged
Approved by: William Grant
Approved revision: 4793ee3df1c1700fa8487fd4bd0079dcd0f29cf9
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~wgrant/launchpad:bprdc-ios
Merge into: launchpad:master
Diff against target: 14 lines (+8/-0)
1 file modified
database/schema/patch-2210-01-4.sql (+8/-0)
Reviewer Review Type Date Requested Status
Colin Watson (community) db Approve
Review via email: mp+379942@code.launchpad.net

Commit message

Index BinaryPackageReleaseDownloadCount for index-only scans

Description of the change

Creating an index on binarypackagereleasedownloadcount (archive, binary_package_release, day, count) allows BinaryPackagePublishingHistory.getDailyDownloadTotals and Archive.getPackageDownloadCount to execute as index-only scans and not touch the heap at all. One sample query drops from 2789 page reads to 177.

Should be applied hot.

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) :
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-2210-01-4.sql b/database/schema/patch-2210-01-4.sql
2new file mode 100644
3index 0000000..be8b2d2
4--- /dev/null
5+++ b/database/schema/patch-2210-01-4.sql
6@@ -0,0 +1,8 @@
7+-- Copyright 2020 Canonical Ltd. This software is licensed under the
8+-- GNU Affero General Public License version 3 (see the file LICENSE).
9+
10+CREATE INDEX binarypackagereleasedownloadcount__index_only_scan__idx
11+ ON binarypackagereleasedownloadcount (
12+ archive, binary_package_release, day, country, count);
13+
14+INSERT INTO LaunchpadDatabaseRevision VALUES (2210, 01, 4);

Subscribers

People subscribed via source and target branches

to status/vote changes: