SELECT * FROM realisation r WHERE r.realisation_category_id = rc.id AND r.site_id = 1 AND rc.parent_id is not null
) OR EXISTS (
SELECT * FROM post p WHERE p.realisation_category_id = rc.id AND p.site_id = 1 AND rc.parent_id is not null
);
Seq Scan on realisation_category rc (cost=0.00..1041.12 rows=33 width=520)
Filter: ((SubPlan 1) OR (SubPlan 2))
SubPlan 1
-> Result (cost=0.00..61.53 rows=6 width=0)
One-Time Filter: (rc.parent_id IS NOT NULL)
-> Seq Scan on realisation r (cost=0.00..61.53 rows=6 width=0)
Filter: ((realisation_category_id =
rc.id) AND (site_id = 1))
SubPlan 2
-> Result (cost=9.34..13.35 rows=1 width=0)
One-Time Filter: (rc.parent_id IS NOT NULL)
-> Bitmap Heap Scan on post p (cost=9.34..13.35 rows=1 width=0)
Recheck Cond: ((site_id = 1) AND (realisation_category_id =
rc.id))
-> BitmapAnd (cost=9.34..9.34 rows=1 width=0)
-> Bitmap Index Scan on idx_5a8a6c8df6bd1646 (cost=0.00..4.37 rows=12 width=0)
Index Cond: (site_id = 1)
-> Bitmap Index Scan on idx_5a8a6c8dd4f97f1a (cost=0.00..4.71 rows=58 width=0)
Index Cond: (realisation_category_id =
rc.id)