同表组的表关联查询为啥执行计划是distribute table scan

【 使用环境 】生产环境
【 OB or 其他组件 】ob
【 使用版本 】4.2.2
【问题描述】
如图表plat_order_pick_detail_his、plat_order_main属于同一表组,并且主副本都调度到了同一机器

查看如下关联查询执行计划:
explain EXTENDED
SELECT
pd.id
,pom.id
from plat_order_pick_detail_his pd
left join plat_order_main pom on pd.order_id=pom.id
where pd.packing_time BETWEEN date_add(now(),interval -30 day) AND now();


显示关联plat_order_main表时,使用的distributed table scan。

这两张表也都刚刚执行过统计信息收集:
CALL dbms_stats.gather_table_stats(‘trade_online’, ‘plat_order_main’, degree=>‘64’, granularity=>‘ALL’);
CALL dbms_stats.gather_table_stats(‘trade_online’, ‘plat_order_pick_detail_his’, degree=>‘64’, granularity=>‘ALL’);

explain 详情.txt (4.0 KB)

也使用系统租户清理过执行计划缓存
ALTER SYSTEM FLUSH PLAN CACHE

1 个赞

不带任何where条件,关联查询就是本地关联了

随便带个pd的where条件,关联查询就成跨机关联了

只是你这个case中走das路径代价更小而已,你可以看到你本地的计划类型还是local

首先das是一种统一的数据源读取路径,不需要关心表的分布,你这个计划对于表pom会生成两种计划,一种是正常的基表计划和一种das扫描计划,然后比较代价选中nlj

你可以在你现在的这个sql的基础上加上/+NO_USE_DAS(pom)/ 看下另一种计划

1 个赞


explain.txt (4.0 KB)

不用das,也是distributed table get


hint没生效,你的链接串可能没加-c

1 个赞