首页 > 数据库 >spark sql语句性能优化及执行计划

spark sql语句性能优化及执行计划

时间:2024-10-19 12:20:43浏览次数:1  
标签:语句 count group distinct 优化 sql spark where 替换

一、优化点:
1、not in 替换为 not exist;
2、in 替换为 right join;
3、distinct 替换为 group by;
4、count(distinct) 替换为 count;
5、where条件中,等号左右两边的数据类型需要一致;
6、where条件中,等号左边不要有函数;
7、where条件上移;
8、优化点需要对照执行计划,并且有实际效果。

二、对应的执行计划:

1、not in 替换为 not exist:

 

 

2、exists替换为in:

 3、distinct替换为group by:

 4、count(distinct)替换为group by:

 5、where条件上移:

 6、数据类型需要一致:

 

标签:语句,count,group,distinct,优化,sql,spark,where,替换
From: https://www.cnblogs.com/chenhongyi/p/18475750

相关文章