近期因CK中query_log表空间占用过大问题,导致磁盘使用率很高,通过查阅资料发现可以通过TTL策略进行清理。同时补充了一些相关的查询SQL,以及注意事项(供参考)。
alter table system.表名 modify TTL 日期字段 + INTERVAL 天数 DAY;设置ttl策略的表必须有日期字段,DAY可调整为月、年。
select table, formatReadableSize(sum(bytes)) as size from system.parts where active group by table;select formatReadableSize(sum(bytes)) as size from system.parts where table = '表名' ;select * from system.parts where table = '表名' ;alter table system.表名 drop partition 分区维度;truncate table system.表名;