Merge lp:~wgrant/launchpad/bug-932433 into lp:launchpad

Proposed by William Grant
Status: Merged
Approved by: William Grant
Approved revision: no longer in the source branch.
Merged at revision: 14804
Proposed branch: lp:~wgrant/launchpad/bug-932433
Merge into: lp:launchpad
Diff against target: 33 lines (+6/-3)
1 file modified
lib/lp/registry/model/distroseries.py (+6/-3)
To merge this branch: bzr merge lp:~wgrant/launchpad/bug-932433
Reviewer Review Type Date Requested Status
Steve Kowalik (community) code Approve
Review via email: mp+93110@code.launchpad.net

Commit message

[r=stevenk][bug=932433] Fix DistroSeriesSet.getCurrentSourceReleases to filter on SPPH's SPN instead of SPR's, so the selection is all on a single fast table.

Description of the change

Now that SPPH.sourcepackagename exists and is populated, most package queries can be fully selective on just SPPH, allowing postgres to be quick with its BitmapAnd magic. This branch changes DistroSeriesSet.getCurrentSourceReleases to take advantage of this, taking it down from ~25ms to ~1ms with hot indices.

To post a comment you must log in.
Revision history for this message
Steve Kowalik (stevenk) wrote :

More use of the de-normalised data, excellent.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/registry/model/distroseries.py'
2--- lib/lp/registry/model/distroseries.py 2012-02-08 06:00:46 +0000
3+++ lib/lp/registry/model/distroseries.py 2012-02-15 00:33:20 +0000
4@@ -1846,7 +1846,7 @@
5 # wrapped anyway - and sqlvalues goes boom.
6 archives = removeSecurityProxy(
7 distroseries.distribution.all_distro_archive_ids)
8- clause = """(spr.sourcepackagename IN %s AND
9+ clause = """(spph.sourcepackagename IN %s AND
10 spph.archive IN %s AND
11 spph.distroseries = %s)
12 """ % sqlvalues(source_package_ids, archives, distroseries.id)
13@@ -1860,7 +1860,8 @@
14 (SourcePackageRelease, DistroSeries.id), SQL("""
15 (SourcePackageRelease.id, DistroSeries.id) IN (
16 SELECT
17- DISTINCT ON (spr.sourcepackagename, spph.distroseries)
18+ DISTINCT ON (
19+ spph.sourcepackagename, spph.distroseries)
20 spr.id, spph.distroseries
21 FROM
22 SourcePackageRelease AS spr,
23@@ -1870,7 +1871,9 @@
24 AND spph.status IN %s
25 AND %s
26 ORDER BY
27- spr.sourcepackagename, spph.distroseries, spph.id DESC
28+ spph.sourcepackagename,
29+ spph.distroseries,
30+ spph.id DESC
31 )
32 """
33 % (sqlvalues(active_publishing_status) + (combined_clause,))))