SQL优化技巧 - 投影下推
· 阅读需 3 分钟
问题定义
投影下推(Projection Pushdown)指的通过删除DT子查询中无意义的列(在外查询中没有使用),来减少IO和网络的代价,同时提升优化器在进行表访问的规划时,采用无需回表的优化选项的几率。
考虑下面的例子,
SELECT count(1) FROM (SELECT c_custkey, avg(age) FROM customer group by c_custkey) AS derived_t1;
重写后的SQL为,
SELECT count(1) FROM (SELECT 1 FROM customer group by c_custkey) AS derived_t1;