From 0bd173dd930d8735a3f111b7324aab9af414e238 Mon Sep 17 00:00:00 2001 From: Simon Larsen Date: Thu, 18 Apr 2024 12:04:48 +0100 Subject: [PATCH] Add basic ops query to check size of tables in Clickhouse --- HelmChart/Docs/Clickhouse.md | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/HelmChart/Docs/Clickhouse.md b/HelmChart/Docs/Clickhouse.md index e22d16a48de..6c94ef8bfce 100644 --- a/HelmChart/Docs/Clickhouse.md +++ b/HelmChart/Docs/Clickhouse.md @@ -13,4 +13,27 @@ then you should be able to access from the localhost and port 8123 kubectl get secret/oneuptime-clickhouse -o go-template='{{(index .data "admin-password") | base64decode}}' ``` -Important: Please ignore % in the end of the password output. \ No newline at end of file +Important: Please ignore % in the end of the password output. + + +### Basic Ops Queries + + +#### Check Size of Tables in Clickhouse + +```sql +SELECT + database, + table, + formatReadableSize(sum(data_compressed_bytes) AS size) AS compressed, + formatReadableSize(sum(data_uncompressed_bytes) AS usize) AS uncompressed, + round(usize / size, 2) AS compr_rate, + sum(rows) AS rows, + count() AS part_count +FROM system.parts +WHERE (active = 1) AND (database LIKE '%') AND (table LIKE '%') +GROUP BY + database, + table +ORDER BY size DESC; +``` \ No newline at end of file