QUERY PLAN -------------------------------------------------------------------------------------------------- Nested Loop (cost=xxx rows=1 width=19) CTE c1 -> Aggregate (cost=xxx rows=1 width=4) -> Merge Join (cost=xxx rows=100 width=4) Merge Cond: (t1_1.c1 = t2.c1) -> Index Only Scan using t1_i1 on t1 t1_1 (cost=xxx rows=1000 width=4) -> Sort (cost=xxx rows=100 width=4) Sort Key: t2.c1 -> Seq Scan on t2 (cost=xxx rows=100 width=4) -> CTE Scan on c1 (cost=xxx rows=1 width=4) -> Index Scan using t1_i1 on t1 (cost=xxx rows=1 width=15) Index Cond: (c1 = c1.c1) (12 rows) QUERY PLAN -------------------------------------------------------------------------------------------------- Nested Loop (cost=xxx rows=2 width=19) CTE c1 -> Aggregate (cost=xxx rows=1 width=4) -> Merge Join (cost=xxx rows=1 width=4) Merge Cond: (t1_1.c1 = t2.c1) -> Index Only Scan using t1_i1 on t1 t1_1 (cost=xxx rows=1000 width=4) -> Sort (cost=xxx rows=100 width=4) Sort Key: t2.c1 -> Seq Scan on t2 (cost=xxx rows=100 width=4) -> CTE Scan on c1 (cost=xxx rows=1 width=4) -> Index Scan using t1_i1 on t1 (cost=xxx rows=1 width=15) Index Cond: (c1 = c1.c1) (12 rows)