微慑信息网

clickhouse查看数据库及表空间大小语句

clickhouse查看数据库及表空间大小语句
1、查看数据库容量、行数、压缩率
select 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;

注意在clickhouse-client客户端执行不能有换行

2、查看数据表容量、行数、压缩率
SELECT 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 table IN ('t_order') GROUP BY table 
3、查看数据表分区信息
SELECT partition 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 IN ('dd_order')) AND (table IN ('t_order')) AND (partition LIKE '2019-12-%') GROUP BY partition ORDER BY partition ASC
4、查看数据表字段的信息
SELECT column AS `字段名`,any(type) AS `类型`,formatReadableSize(sum(column_data_uncompressed_bytes)) AS `原始大小`,formatReadableSize(sum(column_data_compressed_bytes)) AS `压缩大小`,sum(rows) AS `行数` FROM system.parts_columns WHERE (database = 'dd_order') AND (table = 't_order') GROUP BY column ORDER BY column ASC


相关博客
赞(0) 打赏
转载请附本站链接,未经允许不得转载,,谢谢:微慑信息网-VulSee.com » clickhouse查看数据库及表空间大小语句

微慑信息网 专注工匠精神

微慑信息网-VulSee.com-关注前沿安全态势,聚合网络安全漏洞信息,分享安全文档案例

访问我们联系我们

觉得文章有用就打赏一下文章作者

非常感谢你的打赏,我们将继续提供更多优质内容,让我们一起创建更加美好的网络世界!

支付宝扫一扫

微信扫一扫

登录

找回密码

注册