explain (costs off) select *
from t1 inner join t2 on t1.a = t2.x and t1.b = t2.y
group by t1.a,t1.b,t1.c,t1.d,t2.x,t2.y,t2.z;
- QUERY PLAN
--------------------------------------------------------------
+ QUERY PLAN
+------------------------------------------------------------
Remote Fast Query Execution
Node/s: datanode_1, datanode_2
- -> Group
+ -> HashAggregate
Group Key: t1.a, t1.b, t2.x, t2.y
- -> Merge Join
- Merge Cond: ((t1.a = t2.x) AND (t1.b = t2.y))
- -> Index Scan using t1_pkey on t1
- -> Index Scan using t2_pkey on t2
-(8 rows)
+ -> Hash Join
+ Hash Cond: ((t2.x = t1.a) AND (t2.y = t1.b))
+ -> Seq Scan on t2
+ -> Hash
+ -> Seq Scan on t1
+(9 rows)
-- Test case where t1 can be optimized but not t2
explain (costs off) select t1.*,t2.x,t2.z
from t1 inner join t2 on t1.a = t2.x and t1.b = t2.y
group by t1.a,t1.b,t1.c,t1.d,t2.x,t2.z;
- QUERY PLAN
--------------------------------------------------------------
+ QUERY PLAN
+------------------------------------------------------------
Remote Fast Query Execution
Node/s: datanode_1, datanode_2
-> HashAggregate
Group Key: t1.a, t1.b, t2.x, t2.z
- -> Merge Join
- Merge Cond: ((t1.a = t2.x) AND (t1.b = t2.y))
- -> Index Scan using t1_pkey on t1
- -> Index Scan using t2_pkey on t2
-(8 rows)
+ -> Hash Join
+ Hash Cond: ((t2.x = t1.a) AND (t2.y = t1.b))
+ -> Seq Scan on t2
+ -> Hash
+ -> Seq Scan on t1
+(9 rows)
-- Cannot optimize when PK is deferrable
explain (costs off) select * from t3 group by a,b,c;