1、单节点查询库表存储占用
‘system’:库名
SELECT
database AS `库名`,
table AS `表名`,
sum(rows) AS `总行数`,
formatReadableSize(sum(data_uncompressed_bytes)) AS `原始大小`,
formatReadableSize(sum(data_compressed_bytes)) AS `压缩大小`,
round((sum(data_compressed_bytes) / sum(data_uncompressed_bytes)) * 100, 0) AS `压缩率`
FROM system.parts
WHERE database ='system'
GROUP BY
database,
table
ORDER BY
database ASC,
table ASC
2、集群查询库表存储占用
'itsm_cluster':集群名称
'monitor_platform':库名
SELECT
database AS `库名`,
table AS `表名`,
sum(rows) AS `总行数`,
formatReadableSize(sum(data_uncompressed_bytes)) AS `原始大小`,
formatReadableSize(sum(data_compressed_bytes)) AS `压缩大小`,
round((sum(data_compressed_bytes) / sum(data_uncompressed_bytes)) * 100, 0) AS `压缩率`
FROM clusterAllReplicas('itsm_cluster', system.parts)
WHERE database ='monitor_platform'
GROUP BY
database,
table
ORDER BY
database ASC,
table ASC