TD查询表的倾斜率
SELECT T1.DATABASENAME, --库名
T1.TABLENAME, --表名
T1.SPACE_SUM, --表大小
T1.SPACE_MAX, --最大AMP大小
T1.SPACE_AVG, --平均AMP大小
T1.SKEWFACTOR --PI倾斜度
FROM (SELECT DATABASENAME,
TABLENAME,
SUM(CURRENTPERM) / 1000 / 1000 AS SPACE_SUM,
MAX(CURRENTPERM) / 1000 / 1000 AS SPACE_MAX,
AVG(CURRENTPERM) / 1000 / 1000 AS SPACE_AVG,
(SPACE_MAX - SPACE_AVG) / SPACE_MAX * 100 AS SKEWFACTOR
FROM DBC.TABLESIZE
WHERE DATABASENAME = 'DTEMP'
AND UPPER(TABLENAME) NOT LIKE '%_MI_%'
AND UPPER(TABLENAME) NOT LIKE '%_MS_%'
GROUP BY 1, 2) T1
WHERE T1.SKEWFACTOR >= 30
ORDER BY SKEWFACTOR DESC;