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
=== modified file 'lib/lp/registry/model/distroseries.py'
--- lib/lp/registry/model/distroseries.py 2012-02-08 06:00:46 +0000
+++ lib/lp/registry/model/distroseries.py 2012-02-15 00:33:20 +0000
@@ -1846,7 +1846,7 @@
1846 # wrapped anyway - and sqlvalues goes boom.1846 # wrapped anyway - and sqlvalues goes boom.
1847 archives = removeSecurityProxy(1847 archives = removeSecurityProxy(
1848 distroseries.distribution.all_distro_archive_ids)1848 distroseries.distribution.all_distro_archive_ids)
1849 clause = """(spr.sourcepackagename IN %s AND1849 clause = """(spph.sourcepackagename IN %s AND
1850 spph.archive IN %s AND1850 spph.archive IN %s AND
1851 spph.distroseries = %s)1851 spph.distroseries = %s)
1852 """ % sqlvalues(source_package_ids, archives, distroseries.id)1852 """ % sqlvalues(source_package_ids, archives, distroseries.id)
@@ -1860,7 +1860,8 @@
1860 (SourcePackageRelease, DistroSeries.id), SQL("""1860 (SourcePackageRelease, DistroSeries.id), SQL("""
1861 (SourcePackageRelease.id, DistroSeries.id) IN (1861 (SourcePackageRelease.id, DistroSeries.id) IN (
1862 SELECT1862 SELECT
1863 DISTINCT ON (spr.sourcepackagename, spph.distroseries)1863 DISTINCT ON (
1864 spph.sourcepackagename, spph.distroseries)
1864 spr.id, spph.distroseries1865 spr.id, spph.distroseries
1865 FROM1866 FROM
1866 SourcePackageRelease AS spr,1867 SourcePackageRelease AS spr,
@@ -1870,7 +1871,9 @@
1870 AND spph.status IN %s1871 AND spph.status IN %s
1871 AND %s1872 AND %s
1872 ORDER BY1873 ORDER BY
1873 spr.sourcepackagename, spph.distroseries, spph.id DESC1874 spph.sourcepackagename,
1875 spph.distroseries,
1876 spph.id DESC
1874 )1877 )
1875 """1878 """
1876 % (sqlvalues(active_publishing_status) + (combined_clause,))))1879 % (sqlvalues(active_publishing_status) + (combined_clause,))))