Agent Skill
2/7/2026

altinity-expert-clickhouse-memory

Diagnose ClickHouse RAM usage, OOM errors, memory pressure, and allocation patterns. Use for memory-related issues and out-of-memory errors.

A
altinity
4GitHub Stars
1Views
npx skills add Altinity/Skills

SKILL.md

Namealtinity-expert-clickhouse-memory
DescriptionDiagnose ClickHouse RAM usage, OOM errors, memory pressure, and allocation patterns. Use for memory-related issues and out-of-memory errors.

name: altinity-expert-clickhouse-memory description: Diagnose ClickHouse RAM usage, OOM errors, memory pressure, and allocation patterns. Use for memory-related issues and out-of-memory errors.

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 max_threads pragma to limit parallelism
  • Restructure query to reduce group by cardinality

High Memory from JOINs

Solutions:

  • Use max_bytes_in_join
  • Consider join_algorithm = 'partial_merge' or 'auto'
  • Ensure smaller table on right side

Ad-Hoc Query Guidelines

Required Safeguards

-- Always time-bound log queries
where event_date >= today() - 1

-- Limit results
limit 100

Memory-Related Metrics

  • MemoryTracking - current tracked memory
  • MemoryResident - RSS
  • OSMemoryTotal, OSMemoryFreeWithoutCached - system memory

Cross-Module Triggers

FindingLoad ModuleReason
High merge memoryaltinity-expert-clickhouse-mergesAnalyze merge patterns
Large dictionariesaltinity-expert-clickhouse-dictionariesDictionary optimization
Cache too largealtinity-expert-clickhouse-cachesCache sizing
PK memory highaltinity-expert-clickhouse-schemaORDER BY optimization
Query OOMsaltinity-expert-clickhouse-reportingQuery optimization

Settings Reference

SettingScopeNotes
max_memory_usageQueryPer-query limit
max_memory_usage_for_userUserPer-user aggregate
max_server_memory_usageServerGlobal limit
max_server_memory_usage_to_ram_ratioServerAuto-limit as % of RAM
max_bytes_before_external_group_byQuerySpill aggregation to disk
max_bytes_in_joinQuerySpill join to disk
Skills Info
Original Name:altinity-expert-clickhouse-memoryAuthor:altinity