ODPS_数据倾斜查看key分布的通用方案_200628

产生数据倾斜的通用方案

知道数据倾斜了,但无法获知数据倾斜的key信息,可以使用以下方法查看数据倾斜。

假如select * from tba join tbb on tba.id=tbb.id; 产生了数据倾斜
可以执行如下语句来查看key的分布:
select left.key,left.cnt*right.cnt 
from(select key,count(*) as cnt from tba group by key) as left 
join
(select key,count(*) as cnt from tbb group by key) as right
on left.key=right.key;

你可能感兴趣的:(大数据,MaxCompute,SQL)