Merge lp:~rvb/launchpad/bugs-timeout-bug-892820 into lp:launchpad

Proposed by Raphaël Badin
Status: Merged
Approved by: Raphaël Badin
Approved revision: no longer in the source branch.
Merged at revision: 14409
Proposed branch: lp:~rvb/launchpad/bugs-timeout-bug-892820
Merge into: lp:launchpad
Diff against target: 47 lines (+14/-17)
1 file modified
lib/lp/bugs/model/bugtask.py (+14/-17)
To merge this branch: bzr merge lp:~rvb/launchpad/bugs-timeout-bug-892820
Reviewer Review Type Date Requested Status
Benji York (community) code Approve
Review via email: mp+83631@code.launchpad.net

Commit message

[r=benji][bug=892820] Avoid joins in a subquery to improve performance.

To post a comment you must log in.
Revision history for this message
Benji York (benji) wrote :

Looks good.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/bugs/model/bugtask.py'
--- lib/lp/bugs/model/bugtask.py 2011-11-28 00:54:24 +0000
+++ lib/lp/bugs/model/bugtask.py 2011-11-28 16:10:21 +0000
@@ -1375,7 +1375,7 @@
1375 if role.in_admin:1375 if role.in_admin:
1376 return True1376 return True
13771377
1378 # Similar to admins, the Bug Watch Updater, Bug Importer and 1378 # Similar to admins, the Bug Watch Updater, Bug Importer and
1379 # Janitor can always change bug details.1379 # Janitor can always change bug details.
1380 if (1380 if (
1381 role.in_bug_watch_updater or role.in_bug_importer or1381 role.in_bug_watch_updater or role.in_bug_importer or
@@ -2213,22 +2213,19 @@
2213 # is not for subscription to notifications.2213 # is not for subscription to notifications.
2214 # See bug #1918092214 # See bug #191809
2215 if params.bug_supervisor:2215 if params.bug_supervisor:
2216 bug_supervisor_clause = """BugTask.id IN (2216 bug_supervisor_clause = """(
2217 SELECT BugTask.id FROM BugTask, Product2217 BugTask.product IN (
2218 WHERE BugTask.product = Product.id2218 SELECT id FROM Product
2219 AND Product.bug_supervisor = %(bug_supervisor)s2219 WHERE Product.bug_supervisor = %(bug_supervisor)s)
2220 UNION ALL2220 OR
2221 SELECT BugTask.id2221 ((BugTask.distribution, Bugtask.sourcepackagename) IN
2222 FROM BugTask, StructuralSubscription2222 (SELECT distribution, sourcepackagename FROM
2223 WHERE2223 StructuralSubscription
2224 BugTask.distribution = StructuralSubscription.distribution2224 WHERE subscriber = %(bug_supervisor)s))
2225 AND BugTask.sourcepackagename =2225 OR
2226 StructuralSubscription.sourcepackagename2226 BugTask.distribution IN (
2227 AND StructuralSubscription.subscriber = %(bug_supervisor)s2227 SELECT id from Distribution WHERE
2228 UNION ALL2228 Distribution.bug_supervisor = %(bug_supervisor)s)
2229 SELECT BugTask.id FROM BugTask, Distribution
2230 WHERE BugTask.distribution = Distribution.id
2231 AND Distribution.bug_supervisor = %(bug_supervisor)s
2232 )""" % sqlvalues(bug_supervisor=params.bug_supervisor)2229 )""" % sqlvalues(bug_supervisor=params.bug_supervisor)
2233 extra_clauses.append(bug_supervisor_clause)2230 extra_clauses.append(bug_supervisor_clause)
22342231