Colin Watson has proposed merging ~cjwatson/launchpad:avoid-pristine-ppas-optimize into launchpad:master.
Commit message: Optimize getArchivesForDistribution(exclude_pristine=True) Requested reviews: Launchpad code reviewers (launchpad-reviewers) For more details, see: https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/400911 The previous approach of joining SourcePackagePublishingHistory was extremely expensive. An EXISTS subselect is much quicker (and lets us drop the DISTINCT as a bonus). -- Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:avoid-pristine-ppas-optimize into launchpad:master.
diff --git a/lib/lp/soyuz/model/archive.py b/lib/lp/soyuz/model/archive.py index 5d77a81..0fbca87 100644 --- a/lib/lp/soyuz/model/archive.py +++ b/lib/lp/soyuz/model/archive.py @@ -30,6 +30,7 @@ from storm.expr import ( Cast, Count, Desc, + Exists, Join, Not, Or, @@ -2954,13 +2955,14 @@ class ArchiveSet: extra_exprs.append(Archive._enabled == True) if exclude_pristine: - extra_exprs.append( - SourcePackagePublishingHistory.archive == Archive.id) + extra_exprs.append(Exists(Select( + 1, tables=[SourcePackagePublishingHistory], + where=(SourcePackagePublishingHistory.archive == Archive.id)))) query = Store.of(distribution).find( Archive, Archive.distribution == distribution, - *extra_exprs).config(distinct=True) + *extra_exprs) return query.order_by(Archive.name)
_______________________________________________ Mailing list: https://launchpad.net/~launchpad-reviewers Post to : launchpad-reviewers@lists.launchpad.net Unsubscribe : https://launchpad.net/~launchpad-reviewers More help : https://help.launchpad.net/ListHelp