~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/registry/model/distroseriesdifference.py

[r=allenap][bug=798301] Make most_recent_publications() faster by
 avoiding a join through DistroSeries.

Show diffs side-by-side

added added

removed removed

Lines of Context:
118
118
        )
119
119
    conditions = And(
120
120
        DistroSeriesDifference.id.is_in(dsd.id for dsd in dsds),
121
 
        # The + 0 below prevents PostgreSQL from using the (archive, status)
122
 
        # index on SourcePackagePublishingHistory, the use of which results in
123
 
        # a terrible query plan.
 
121
        # XXX: GavinPanella 2011-06-23 bug=801097: The + 0 in the condition
 
122
        # below prevents PostgreSQL from using the (archive, status) index on
 
123
        # SourcePackagePublishingHistory, the use of which results in a
 
124
        # terrible query plan. This might be indicative of an underlying,
 
125
        # undiagnosed issue in production with wider repurcussions.
124
126
        SourcePackagePublishingHistory.archiveID + 0 == Archive.id,
125
127
        SourcePackagePublishingHistory.sourcepackagereleaseID == (
126
128
            SourcePackageRelease.id),
132
134
    if in_parent:
133
135
        conditions = And(
134
136
            conditions,
135
 
            DistroSeries.id == DistroSeriesDifference.parent_series_id,
136
137
            SourcePackagePublishingHistory.distroseriesID == (
137
138
                DistroSeriesDifference.parent_series_id),
138
139
            )
139
140
    else:
140
141
        conditions = And(
141
142
            conditions,
142
 
            DistroSeries.id == DistroSeriesDifference.derived_series_id,
143
143
            SourcePackagePublishingHistory.distroseriesID == (
144
144
                DistroSeriesDifference.derived_series_id),
145
145
            )
146
146
    # Ensure that the archive has the right purpose.
147
147
    conditions = And(
148
148
        conditions,
149
 
        Archive.distributionID == DistroSeries.distributionID,
150
149
        # DistroSeries.getPublishedSources() matches on MAIN_ARCHIVE_PURPOSES,
151
150
        # but we are only ever going to be interested in PRIMARY archives.
152
151
        Archive.purpose == ArchivePurpose.PRIMARY,