首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >postgres-xl左联接执行时间过长

postgres-xl左联接执行时间过长
EN

Stack Overflow用户
提问于 2018-07-10 13:18:01
回答 2查看 303关注 0票数 0

Postgres-XL 9.5r1.6由一个gtm、一个协调器和两个datanodes组成。

有三个表abc实现了多到多的关系:

代码语言:javascript
复制
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毫秒、

代码语言:javascript
复制
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';

解释协调员的计划:

代码语言:javascript
复制
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)

其他一些人已经碰到了这个问题,并问了here,但没有任何回答或暗示。我只是希望这次这个问题能得到一些启发。

ps:我试图用一种来自ab的相关行的方式填充这三个表,这两个表形成了表c,它们只来自同一个datanode。但执行时间没有改善。值得注意的另一点是,当where子句(a.name='cf82c96b77b8aa5277da6d55c4e4e66e')中的条件始终为false时,执行时间会下降不到几毫秒。

EN

回答 2

Stack Overflow用户

发布于 2018-07-10 14:19:35

对于此查询:

代码语言:javascript
复制
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';

您需要a(name)b(name)c(name)上的索引。分区不会对此查询有所帮助,只有当表非常大时,才应该保留分区。

票数 0
EN

Stack Overflow用户

发布于 2020-03-30 21:26:27

这是由于嵌套循环,将其设置为false。XL将使用散列连接,然后它将快速返回结果。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51266342

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档