clickhouse清理日志。

参考Clickhouse:日志表占用大量磁盘空间怎么办?_clickhouse store目录很大-CSDN博客t

清理脚本如下,清理动作需要时间比较长,10多分钟:

alter table system.trace_log delete where event_date < '2024-01-01'

alter table system.query_log delete where event_date < '2024-01-01'

alter table system.query_thread_log delete where event_date < '2024-01-01'

alter table system.asynchronous_metric_log delete where event_date < '2024-01-01'

查询语句:

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 `压缩率`,

`table` AS `表名`

FROM system.parts where database = 'system' group by `table`

相关推荐
SelectDB18 小时前
阶跃星辰基于 SelectDB 构建 PB 级 Agent 可观测平台
大数据·数据库·aigc
这个DBA有点耶19 小时前
GROUP BY优化全解:如何写出既不丢数据又飞快的分组查询
数据库·mysql·架构
掉头发的王富贵1 天前
【StarRocks】极限十分钟入门StarRocks
数据库·sql·mysql
Nturmoils1 天前
WHERE 条件别凭习惯写,常用查询先跑一遍
数据库
Databend2 天前
在 AWS 中国峰会逛了一天,我在 Databend 展台看到了 Agent 数据基础设施的新思路
数据库·人工智能·agent
ClouGence3 天前
Oracle 数据同步为什么会出现数据不一致?长事务是常被忽略的原因
数据库·后端·oracle
飞将3 天前
从零实现数据库(2)——HashIndex + IndexManager
数据库
Nturmoils4 天前
订单列表慢查询,先看 WHERE、ORDER BY 和 LIMIT
数据库
渣波4 天前
拒绝 SQL 焦虑!手把手带你用 NestJS + Prisma + DTO 写出“防弹”级后端代码
javascript·数据库·后端
倔强的石头_5 天前
KingbaseES 新版MySQL 兼容版体验:旧版迁移 + 功能实测
数据库