altinity-expert-clickhouse-memory
Original:🇺🇸 English
Translated
Diagnose ClickHouse RAM usage, OOM errors, memory pressure, and allocation patterns. Use for memory-related issues and out-of-memory errors.
15installs
Sourcealtinity/skills
Added on
NPX Install
npx skill4agent add altinity/skills altinity-expert-clickhouse-memoryTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →Memory Usage and OOM Diagnostics
Diagnose RAM usage, memory pressure, OOM risks, and memory allocation patterns.
Diagnostics
Run all queries from the file checks.sql and analyze the results.
Problem Investigation
High Memory from Aggregations
Solutions:
- Add
max_bytes_before_external_group_by - Use pragma to limit parallelism
max_threads - Restructure query to reduce group by cardinality
High Memory from JOINs
Solutions:
- Use
max_bytes_in_join - Consider or
join_algorithm = 'partial_merge''auto' - Ensure smaller table on right side
Ad-Hoc Query Guidelines
Required Safeguards
sql
-- Always time-bound log queries
where event_date >= today() - 1
-- Limit results
limit 100Memory-Related Metrics
- - current tracked memory
MemoryTracking - - RSS
MemoryResident - ,
OSMemoryTotal- system memoryOSMemoryFreeWithoutCached
Cross-Module Triggers
| Finding | Load Module | Reason |
|---|---|---|
| High merge memory | | Analyze merge patterns |
| Large dictionaries | | Dictionary optimization |
| Cache too large | | Cache sizing |
| PK memory high | | ORDER BY optimization |
| Query OOMs | | Query optimization |
Settings Reference
| Setting | Scope | Notes |
|---|---|---|
| Query | Per-query limit |
| User | Per-user aggregate |
| Server | Global limit |
| Server | Auto-limit as % of RAM |
| Query | Spill aggregation to disk |
| Query | Spill join to disk |