Comment 12 for bug 736008

Revision history for this message
Robert Collins (lifeless) wrote :

Ok, *this* looks like it performs well - I've thrown a bunch of different projects at it with a 2 second worst case cold query.

with teams as (SELECT team from teamparticipation where person=2),
scope_branches as (SELECT Branch.id, private, owner from Branch where product=10294),
private_branches as (SELECT scope_Branches.id FROM scope_branches where
 scope_branches.private and ((scope_branches.owner in (select team from teams) OR
exists(select true from BranchSubscription, teams where branchsubscription.branch = scope_branches.id and branchsubscription.person = teams.team)))),
candidate_branches as ((select id from private_branches) union (select id from scope_branches where not private))
SELECT COUNT(*)
FROM BranchMergeProposal WHERE source_branch in (select id from candidate_branches) and target_branch in (select id from candidate_branches)
  AND BranchMergeProposal.queue_status IN (3, 2);