1、以如下SQL语句为例:
select d, avg(a::numeric(7, 2)) from t_distinct group by d;
2、执行EXPLAIN的输出为:
gaussdb=# explain select d, avg(a::numeric(7, 2)) from t_distinct group by d; id | operation | E-rows | E-width | E-costs ----+---------------------------------------------------+--------+---------+--------- 1 | -> Row Adapter | 20 | 40 | 14.52 2 | -> Vector Streaming (type: GATHER) | 20 | 40 | 14.52 3 | -> Vector Hash Aggregate | 20 | 40 | 13.59 4 | -> Vector Streaming(type: REDISTRIBUTE) | 20 | 8 | 13.33 5 | -> CStore Scan on t_distinct | 20 | 8 | 13.01 (5 rows)
3、执行计划层级解读(纵向):
- 第一层:CStore Scan on t1
表扫描算子,用CStore Scan的方式扫描表t1。这一层的作用是把表t1的数据从buffer或者磁盘上读上来输送给上层节点参与计算。
- 第二层:Vector Hash Aggregate
- 第三层:Vector Streaming (type: GATHER)
- 第四层:Row Adapter
需要注意的是最顶层算子为Data Node Scan时,需要设置enable_fast_query_shipping为off才能看到具体的执行计划
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




