ClickHouse
November 16, 2023

Полезные запросы по ресурсам к системным таблицам.

Примеры запросов.

# Информация по доступной и потребляемой памяти.
SELECT
    metric,
    formatReadableSize(value) AS r_value
FROM system.asynchronous_metrics
WHERE metric LIKE '%Mem%'
ORDER BY value DESC
# Информация о базах и таблицах в кластере.
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;