Skip to content
altinity-expert-clickhouse-merges logo

Altinity Expert Clickhouse Merges

altinity-expert-clickhouse-merges

Diagnose ClickHouse merge performance, part backlog, and 'too many parts' errors. Use for merge issues and part management problems.

NeverSight/skills_feed0installs215stars

SKILL.md

Full skill instructions

Diagnostics

Run all queries from checks.sql (cluster-wide) one by one and produce a decision-ready report.

Triage Order (Mandatory)

  1. Check current active merges from system.merges.
  2. Check merge success/​failure trend from system.part_log.
  3. Check table-level status (merge_ok, merge_failed, last success/​failure).
  4. Check merge reason + algorithm (merge_reason, merge_algorithm).
  5. Check merge RAM now + historical peak RAM (system.merges.memory_usage, system.part_log.peak_memory_usage).
  6. Check part-count offenders with split:
    • database = 'system'
    • database != 'system'
  7. Check relevant settings, including TTL merge concurrency.

Decision Rules

Use one of these final verdicts explicitly:

  • PROVED: cluster-wide merge stop (no successful merges in the selected window).
  • DECLINED: cluster-wide stop is false.
  • PARTIAL: merges are blocked for specific table(s) while others still merge.

Additional rules:

  • If some tables still have successful merges in same timeframe, do not report global merge stop.
  • If a target table has merge_ok = 0 with repeated MEMORY_LIMIT_EXCEEDED, report table-level block.
  • If merges are 100% Horizontal, state that planner selected horizontal merges (do not say vertical is disabled unless settings prove it).
  • If max part count is driven by system.* tables, call out alert-source mismatch to avoid misattribution to business tables.

Problem-Specific Investigation

"Too Many Parts" Investigation

For a specific table, run ad-hoc checks (time-bound and limited):

select
    toStartOfMinute(event_time) as minute,
    countIf(event_type = 'NewPart') as new_parts,
    countIf(event_type = 'MergeParts') as merges,
    countIf(event_type = 'MergeParts') - countIf(event_type = 'NewPart') as net_reduction
from system.part_log
where database = '{database}'
  and table = '{table}'
  and event_time > now() - interval 1 hour
group by minute
order by minute desc
limit 60

If net_reduction is negative consistently, inserts outpace merges.

TTL merge pressure and merge-size settings snapshot

Check system.merge_tree_settings if modified Suggest changing (reducing or increasing) in case of a problem as remediation.

  • max_parts_to_merge_at_once
  • max_bytes_to_merge_at_max_space_in_pool
  • max_bytes_to_merge_at_min_space_in_pool
  • enable_vertical_merge_algorithm
  • vertical_merge_algorithm_min_rows_to_activate
  • vertical_merge_algorithm_min_columns_to_activate
  • max_number_of_merges_with_ttl_in_pool
  • max_replicated_merges_with_ttl_in_queue
  • parts_to_delay_insert
  • parts_to_throw_insert

Structural Fix Guidance (When Settings Are Not Enough)

Call out anti-patterns explicitly:

  • Single hot partition (partition_id='all')
  • Heavy TTL ... GROUP BY ... SET ... on a hot ingestion table
  • Persistent large horizontal merge attempts with OOM failures

Recommended long-term direction:

  • Add time-based partitioning
  • Move heavy rollup logic from TTL path to MV/​batch table
  • Keep base-table TTL simple (delete-oriented)

Ad-Hoc Query Guidelines

Required Safeguards

-- Always include LIMIT
limit 100

-- Always time-bound historical queries
where event_time >= now() - interval 24 hour

-- For part_log, always filter event_type
where event_type in ('NewPart', 'MergeParts', 'MutatePart')

Avoid

  • select * from system.part_log
  • Unbounded scans on *_log tables
  • Large joins in-context (aggregate in SQL)

Cross-Module Triggers

FindingLoad ModuleReason
High memory during merges / OOMaltinity-expert-clickhouse-memoryMemory limits and pressure
Slow merges + normal diskaltinity-expert-clickhouse-schemaORDER BY/​partitioning anti-patterns
Slow merges + high disk IOaltinity-expert-clickhouse-storageStorage bottleneck
Merges blocked by mutationsaltinity-expert-clickhouse-mutationsMutation backlog
Replication lag + merge issuesaltinity-expert-clickhouse-replicationQueue/​replica bottlenecks

Final Report Sections (Mandatory)

  1. Environment header
  2. Global vs table-specific merge status
  3. Current and peak merge RAM
  4. Merge reason and merge algorithm findings
  5. Max-part offenders (system vs non-system)
  6. Current settings and recommended deltas
  7. Immediate mitigation and structural remediation

More skills from NeverSight

devops-deployer logo
NeverSight/skills_feed

devops-deployer

Comprehensive DevOps and deployment workflow that orchestrates infrastructure automation, CI/CD pipelines, container orchestration, and cloud deployment. Handles everything from infrastructure as code and pipeline setup to monitoring, scaling, and disaster recovery.

215 1
View
avnu logo
NeverSight/skills_feed

avnu

Integrate avnu SDK for Starknet DeFi: token swaps with best-price routing, DCA recurring buys, native staking, gasless transactions via paymaster, and market data. Use when building Starknet trading, DEX aggregation, or DeFi automation features.

215 0
View
post-to-x logo
NeverSight/skills_feed

post-to-x

发布内容和文章到 X (Twitter)。支持带图片的普通推文和 X Articles(长文)。使用真实的 Chrome 和 CDP 来绕过自动化检测。

215 0
View
ralph-prompt-builder logo
NeverSight/skills_feed

ralph-prompt-builder

Master orchestrator for generating Ralph Wiggum-compatible prompts. Analyzes task requirements and routes to appropriate generator (single-task, multi-task, project, or research). Use when you need to create any Ralph loop prompt and want automatic selection of the right generator.

215 0
View
branch-comparison logo
NeverSight/skills_feed

branch-comparison

Use when the user asks to compare branches, analyze git diffs, review changes between branches, update specifications based on code changes, or analyze what changed. Triggers on keywords like "compare branches", "git diff", "what changed", "branch comparison", "code changes", "spec update".

215 0
View
fastapi-development logo
NeverSight/skills_feed

fastapi-development

Build high-performance FastAPI applications with async routes, validation, dependency injection, security, and automatic API documentation. Use when developing modern Python APIs with async support, automatic OpenAPI documentation, and high performance requirements.

215 0
View
zendesk-chat logo
NeverSight/skills_feed

zendesk-chat

Enables Claude to manage Zendesk Chat conversations, support tickets, and customer service operations

215 0
View
forge logo
NeverSight/skills_feed

forge

Mine transcripts for knowledge - decisions, learnings, failures, patterns. Triggers: "forge insights", "mine transcripts", "extract knowledge".

215 0
View
mixpanel logo
NeverSight/skills_feed

mixpanel

Track product analytics and user behavior with Mixpanel's event-based platform.

215 0
View
ocpp logo
NeverSight/skills_feed

ocpp

OCPP protocol reference for EV charging infrastructure development. Covers OCPP 2.0.1 and OCPP 1.6J. Use when working with OCPP messages, charging station code, CSMS/Central System backends, smart charging, transaction handling, or EV charging protocols. Activates on keywords: OCPP, charging stat...

215 0
View
bee-collect logo
NeverSight/skills_feed

bee-collect

Gather scattered ideas into organized GitHub issues. The bee collects pollen from every flower, checks if the hive already has it, and carefully deposits new work in the comb for later. Never edits code—only organizes the work ahead. Use when creating issues from TODOs or planning work.

215 0
View
vercel-react-native-skills logo
NeverSight/skills_feed

vercel-react-native-skills

Comprehensive best practices for React Native and Expo applications. Contains rules across multiple categories covering performance, animations, UI patterns, and platform-specific optimizations.

215 0
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View