产生数据倾斜的通用方案
知道数据倾斜了,但无法获知数据倾斜的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;