ClickHouse Error 241: Memory limit (for query) exceeded

Large `GROUP BY` or `JOIN` exceeded `max_memory_usage` without external spill enabled.

Runs locally in browser Free · No login Independently Verified 2026-11-25 v4.1.0
Identifier: ClickHouse Error 241 Platform: Databases
Common Root Causes:
  • Large `GROUP BY` or `JOIN` exceeded `max_memory_usage` without external spill enabled.

Interactive Diagnostic Checklist

Verified Solutions:
  1. Order JOIN with smaller table on the right and enable `max_bytes_before_external_group_by`.
Safe Diagnostic Command:
Inspect `system.query_log` memory_usage column
Warning: Verify configuration changes in staging or with dry-run flags (e.g. nginx -t) before reloading production services.

Technical Explanation

Large `GROUP BY` or `JOIN` exceeded `max_memory_usage` without external spill enabled. Recommended diagnostic: `Inspect `system.query_log` memory_usage column`. Remediation: Order JOIN with smaller table on the right and enable `max_bytes_before_external_group_by`.

Worked Examples

  • Run `Inspect `system.query_log` memory_usage column` to verify root cause before applying the remediation.

Limitations & Assumptions

  • Always verify configuration changes in staging or with dry-run flags (e.g. `nginx -t`) before reloading production services.

Source References & Verification

Resource ID: err-clickhouse-memory-limit-exceeded · Independently verified: 2026-11-25

Related Resources