explain analyze with bugbranches as (select bugbranch.bug, bugbranch.branch from bugbranch where branch in (451217, 451208, 451207, 451206, 310641, 450226, 449792, 449762, 449192, 449190, 444685, 439423, 436128, 421710, 317004, 374978, 404904, 412011, 411115, 245099, 400223, 377965, 373979, 372939, 372691, 362490, 362566, 362564, 361252, 359795, 359423, 357633, 355943, 348553, 322307, 319438, 316198, 316197, 315929, 310090, 308190, 305716, 305524, 296541, 294443, 245102, 275463, 273980, 40682, 34254, 175815, 152799, 115607, 81913, 81670, 62623, 52209, 42949, 39318, 38448, 37654, 12332, 30797, 21766, 13518, 16918, 12486, 10605, 10457, 5670, 9447, 7882, 4233, 3674, 2510, 2469)) (SELECT BugBranches.branch FROM Bug, BugBranches WHERE Bug.id = BugBranches.bug AND Bug.private = FALSE) UNION (SELECT BugBranches.branch FROM Bug, BugBranches WHERE Bug.id = BugBranches.bug AND Bug.private AND Bug.id IN (SELECT BugSubscription.bug FROM BugSubscription, TeamParticipation WHERE TeamParticipation.team = BugSubscription.person AND TeamParticipation.person = 67034)); QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- HashAggregate (cost=13604.15..13606.09 rows=194 width=4) (actual time=450.964..450.970 rows=18 loops=1) CTE bugbranches -> Seq Scan on bugbranch (cost=0.00..9341.04 rows=97 width=8) (actual time=1.584..160.240 rows=18 loops=1) Filter: (branch = ANY ('{451217,451208,451207,451206,310641,450226,449792,449762,449192,449190,444685,439423,436128,421710,317004,374978,404904,412011,411115,245099,400223,377965,373979,372939,372691,362490,362566,362564,361252,359795,359423,357633,355943,348553,322307,319438,316198,316197,315929,310090,308190,305716,305524,296541,294443,245102,275463,273980,40682,34254,175815,152799,115607,81913,81670,62623,52209,42949,39318,38448,37654,12332,30797,21766,13518,16918,12486,10605,10457,5670,9447,7882,4233,3674,2510,2469}'::integer[])) -> Append (cost=0.00..4262.63 rows=194 width=4) (actual time=1.615..450.934 rows=18 loops=1) -> Nested Loop (cost=0.00..619.49 rows=97 width=4) (actual time=1.614..160.601 rows=18 loops=1) -> CTE Scan on bugbranches (cost=0.00..1.94 rows=97 width=8) (actual time=1.590..160.289 rows=18 loops=1) -> Index Scan using bug_pkey on bug (cost=0.00..6.35 rows=1 width=4) (actual time=0.015..0.015 rows=1 loops=18) Index Cond: (public.bug.id = bugbranches.bug) Filter: (NOT public.bug.private) -> Nested Loop (cost=2967.78..3641.20 rows=97 width=4) (actual time=290.323..290.323 rows=0 loops=1) -> Hash Join (cost=2967.78..3023.65 rows=97 width=12) (actual time=226.778..290.147 rows=9 loops=1) Hash Cond: (bugsubscription.bug = bugbranches.bug) -> HashAggregate (cost=2964.63..3005.25 rows=4062 width=4) (actual time=208.495..267.164 rows=129510 loops=1) -> Nested Loop (cost=0.00..2954.48 rows=4062 width=4) (actual time=0.048..116.630 rows=130835 loops=1) -> Index Scan using teamparticipation_person_idx on teamparticipation (cost=0.00..273.54 rows=106 width=4) (actual time=0.018..0.148 rows=98 loops=1) Index Cond: (person = 67034) -> Index Scan using bugsubscription_person_idx on bugsubscription (cost=0.00..25.17 rows=10 width=8) (actual time=0.006..0.779 rows=1335 loops=98) Index Cond: (bugsubscription.person = teamparticipation.team) -> Hash (cost=1.94..1.94 rows=97 width=8) (actual time=0.030..0.030 rows=18 loops=1) -> CTE Scan on bugbranches (cost=0.00..1.94 rows=97 width=8) (actual time=0.003..0.008 rows=18 loops=1) -> Index Scan using bug_pkey on bug (cost=0.00..6.35 rows=1 width=4) (actual time=0.017..0.017 rows=0 loops=9) Index Cond: (public.bug.id = bugbranches.bug) Filter: public.bug.private Total runtime: 451.182 ms (25 rows)
explain analyze with bugbranches as (select bugbranch.bug, bugbranch.branch from bugbranch where branch in (451217, 451208, 451207, 451206, 310641, 450226, 449792, 449762, 449192, 449190, 444685, 439423, 436128, 421710, 317004, 374978, 404904, 412011, 411115, 245099, 400223, 377965, 373979, 372939, 372691, 362490, 362566, 362564, 361252, 359795, 359423, 357633, 355943, 348553,
TeamParticipat ion on.team = BugSubscription .person on.person = 67034));
QUERY PLAN ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ------- ----- 15..13606. 09 rows=194 width=4) (actual time=450. 964..450. 970 rows=18 loops=1) 451208, 451207, 451206, 310641, 450226, 449792, 449762, 449192, 449190, 444685, 439423, 436128, 421710, 317004, 374978, 404904, 412011, 411115, 245099, 400223, 377965, 373979, 372939, 372691, 362490, 362566, 362564, 361252, 359795, 359423, 357633, 355943, 348553, 322307, 319438, 316198, 316197, 315929, 310090, 308190, 305716, 305524, 296541, 294443, 245102, 275463, 273980, 40682,34254, 175815, 152799, 115607, 81913,81670, 62623,52209, 42949,39318, 38448,37654, 12332,30797, 21766,13518, 16918,12486, 10605,10457, 5670,9447, 7882,4233, 3674,2510, 2469}': :integer[ ]))
Index Cond: (public.bug.id = bugbranches.bug)
Filter: (NOT public.bug.private) 78..3641. 20 rows=97 width=4) (actual time=290. 323..290. 323 rows=0 loops=1) 78..3023. 65 rows=97 width=12) (actual time=226. 778..290. 147 rows=9 loops=1)
Hash Cond: (bugsubscriptio n.bug = bugbranches.bug)
-> HashAggregate (cost=2964. 63..3005. 25 rows=4062 width=4) (actual time=208. 495..267. 164 rows=129510 loops=1)
- > Nested Loop (cost=0.00..2954.48 rows=4062 width=4) (actual time=0.048..116.630 rows=130835 loops=1)
-> Index Scan using teamparticipati on_person_ idx on teamparticipation (cost=0.00..273.54 rows=106 width=4) (actual time=0.018..0.148 rows=98 loops=1)
Index Cond: (person = 67034)
-> Index Scan using bugsubscription _person_ idx on bugsubscription (cost=0.00..25.17 rows=10 width=8) (actual time=0.006..0.779 rows=1335 loops=98)
Index Cond: (bugsubscriptio n.person = teamparticipati on.team)
-> Hash (cost=1.94..1.94 rows=97 width=8) (actual time=0.030..0.030 rows=18 loops=1)
- > CTE Scan on bugbranches (cost=0.00..1.94 rows=97 width=8) (actual time=0.003..0.008 rows=18 loops=1)
Index Cond: (public.bug.id = bugbranches.bug)
Filter: public.bug.private
322307, 319438, 316198, 316197, 315929, 310090, 308190, 305716, 305524, 296541, 294443, 245102, 275463, 273980, 40682, 34254, 175815, 152799, 115607, 81913, 81670, 62623, 52209, 42949, 39318, 38448, 37654, 12332, 30797, 21766, 13518, 16918, 12486, 10605, 10457, 5670, 9447, 7882, 4233, 3674, 2510, 2469))
(SELECT BugBranches.branch
FROM Bug, BugBranches
WHERE Bug.id = BugBranches.bug
AND Bug.private = FALSE)
UNION
(SELECT BugBranches.branch
FROM Bug, BugBranches
WHERE Bug.id = BugBranches.bug
AND Bug.private AND Bug.id IN
(SELECT BugSubscription.bug
FROM BugSubscription,
WHERE TeamParticipati
AND TeamParticipati
-------
HashAggregate (cost=13604.
CTE bugbranches
-> Seq Scan on bugbranch (cost=0.00..9341.04 rows=97 width=8) (actual time=1.584..160.240 rows=18 loops=1)
Filter: (branch = ANY ('{451217,
-> Append (cost=0.00..4262.63 rows=194 width=4) (actual time=1.615..450.934 rows=18 loops=1)
-> Nested Loop (cost=0.00..619.49 rows=97 width=4) (actual time=1.614..160.601 rows=18 loops=1)
-> CTE Scan on bugbranches (cost=0.00..1.94 rows=97 width=8) (actual time=1.590..160.289 rows=18 loops=1)
-> Index Scan using bug_pkey on bug (cost=0.00..6.35 rows=1 width=4) (actual time=0.015..0.015 rows=1 loops=18)
-> Nested Loop (cost=2967.
-> Hash Join (cost=2967.
-> Index Scan using bug_pkey on bug (cost=0.00..6.35 rows=1 width=4) (actual time=0.017..0.017 rows=0 loops=9)
Total runtime: 451.182 ms
(25 rows)