Postgres-XL 9.5r1.6 由一个 gtm、一个协调器和两个数据节点组成。
共有三个表a
,它们实现b
了c
多对多关系:
create table a(id int, name text, uid int) distribute by hash(uid);
create table b(id int, name text, uid int) distribute by hash(uid);
create table c(id int, aname text, bname text, uid int) distribute by hash(uid);
在协调器上运行以下查询时,它需要莫名其妙的20000 毫秒时间!但在任一数据节点上,执行时间几乎不超过20 毫秒。
select a.name, b.name
from
a left join c
on a.name=c.aname
left join b
on c.bname=b.name
where
a.name='cf82c96b77b8aa5277da6d55c4e4e66e';
解释协调员计划:
Remote Subquery Scan on all (dn_1,dn_2) (cost=8.33..17.78 rows=1 width=66)
-> Nested Loop Left Join (cost=8.33..17.78 rows=1 width=66)
Join Filter: ((a.name)::text = (c.aname)::text)
-> Remote Subquery Scan on all (dn_1,dn_2) (cost=100.15..108.21 rows=1 width=33)
Distribute results by H: name
-> Index Only Scan using code_idx on a (cost=0.15..8.17 rows=1 width=33)
Index Cond: (name = 'cf82c96b77b8aa5277da6d55c4e4e66e'::text)
-> Materialize (cost=108.18..109.72 rows=1 width=115)
-> Remote Subquery Scan on all (dn_1,dn_2) (cost=108.18..109.72 rows=1 width=115)
Distribute results by H: aname
-> Hash Right Join (cost=8.18..9.60 rows=1 width=115)
Hash Cond: ((b.name)::text = (c.bname)::text)
-> Remote Subquery Scan on all (dn_1,dn_2) (cost=100.00..102.44 rows=30 width=33)
Distribute results by H: name
-> Seq Scan on b (cost=0.00..1.30 rows=30 width=33)
-> Hash (cost=108.41..108.41 rows=1 width=244)
-> Remote Subquery Scan on all (dn_1,dn_2) (cost=100.15..108.41 rows=1 width=244)
Distribute results by H: bname
-> Index Only Scan using code_idxcfc on c (cost=0.15..8.17 rows=1 width=244)
Index Cond: (aname = 'cf82c96b77b8aa5277da6d55c4e4e66e'::text)
其他一些人已经遇到了这个问题并在这里问但没有答案或提示。我只是希望这次这个问题能得到一些见解。
a
ps:我尝试以相关行来自和b
表单表c
仅来自同一个数据节点的方式填充三个表。但执行时间没有改善。另一点值得注意的是,当where
子句(a.name='cf82c96b77b8aa5277da6d55c4e4e66e'
)中的条件总是为假时,执行时间会下降到不到几毫秒。