QUERY PLAN ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Aggregate (cost=18024.62..18024.63 rows=1 width=0) (actual time=26.271..26.272 rows=1 loops=1) -> Nested Loop (cost=15086.86..18023.65 rows=388 width=0) (actual time=1.142..26.158 rows=168 loops=1) Join Filter: ((NOT source.private) OR ((hashed SubPlan 1) AND (NOT target.private)) OR ((hashed SubPlan 2) AND (branchmergeproposal.queue_status = ANY ('{3,2}'::integer[])))) -> Nested Loop (cost=6.44..1479.19 rows=397 width=13) (actual time=0.982..22.225 rows=168 loops=1) -> Bitmap Heap Scan on branch source (cost=6.44..561.77 rows=329 width=5) (actual time=0.658..8.537 rows=329 loops=1) Recheck Cond: (product = 7432) -> Bitmap Index Scan on branch__product__id__idx (cost=0.00..6.35 rows=329 width=0) (actual time=0.489..0.489 rows=329 loops=1) Index Cond: (product = 7432) -> Index Scan using branchmergeproposal__source_branch__idx on branchmergeproposal (cost=0.00..2.78 rows=1 width=12) (actual time=0.038..0.039 rows=1 loops=329) Index Cond: (branchmergeproposal.source_branch = source.id) -> Index Scan using branch_pkey on branch target (cost=0.00..3.67 rows=1 width=5) (actual time=0.020..0.021 rows=1 loops=168) Index Cond: (target.id = branchmergeproposal.target_branch) SubPlan 1 -> HashAggregate (cost=7539.86..7540.14 rows=28 width=4) (never executed) -> Append (cost=0.00..7539.79 rows=28 width=4) (never executed) -> Nested Loop (cost=0.00..3694.03 rows=18 width=4) (never executed) -> Index Scan using teamparticipation_person_idx on teamparticipation (cost=0.00..191.83 rows=125 width=4) (never executed) Index Cond: (person = 790463) -> Index Scan using branch_owner_idx on branch (cost=0.00..28.01 rows=1 width=8) (never executed) Index Cond: (public.branch.owner = public.teamparticipation.team) Filter: public.branch.private -> Nested Loop (cost=0.00..3845.48 rows=10 width=4) (never executed) -> Nested Loop (cost=0.00..3760.60 rows=217 width=4) (never executed) -> Index Scan using teamparticipation_person_idx on teamparticipation (cost=0.00..191.83 rows=125 width=4) (never executed) Index Cond: (person = 790463) -> Index Scan using branchsubscription__person__branch__key on branchsubscription (cost=0.00..28.26 rows=23 width=8) (never executed) Index Cond: (public.branchsubscription.person = public.teamparticipation.team) -> Index Scan using branch_pkey on branch (cost=0.00..0.38 rows=1 width=4) (never executed) Index Cond: (public.branch.id = public.branchsubscription.branch) Filter: public.branch.private SubPlan 2 -> HashAggregate (cost=7539.86..7540.14 rows=28 width=4) (never executed) -> Append (cost=0.00..7539.79 rows=28 width=4) (never executed) -> Nested Loop (cost=0.00..3694.03 rows=18 width=4) (never executed) -> Index Scan using teamparticipation_person_idx on teamparticipation (cost=0.00..191.83 rows=125 width=4) (never executed) Index Cond: (person = 790463) -> Index Scan using branch_owner_idx on branch (cost=0.00..28.01 rows=1 width=8) (never executed) Index Cond: (public.branch.owner = public.teamparticipation.team) Filter: public.branch.private -> Nested Loop (cost=0.00..3845.48 rows=10 width=4) (never executed) -> Nested Loop (cost=0.00..3760.60 rows=217 width=4) (never executed) -> Index Scan using teamparticipation_person_idx on teamparticipation (cost=0.00..191.83 rows=125 width=4) (never executed) Index Cond: (person = 790463) -> Index Scan using branchsubscription__person__branch__key on branchsubscription (cost=0.00..28.26 rows=23 width=8) (never executed) Index Cond: (public.branchsubscription.person = public.teamparticipation.team) -> Index Scan using branch_pkey on branch (cost=0.00..0.38 rows=1 width=4) (never executed) Index Cond: (public.branch.id = public.branchsubscription.branch) Filter: public.branch.private Total runtime: 27.202 ms (49 rows) Time: 235.485 ms