v.24.12Improvement
Automatic Disk-Based GROUP BY/ORDER BY Based on Memory Usage
AutomaticGROUP BY/ORDER BYto disk based on the server/user memory usage. Controlled withmax_bytes_ratio_before_external_group_by/max_bytes_ratio_before_external_sortquery settings. #71406 (Azat Khuzhin).
Why it matters
This feature addresses memory pressure issues by enabling ClickHouse to automatically offloadGROUP BY and ORDER BY computations to disk when memory consumption approaches specified thresholds. It helps prevent query failures due to out-of-memory errors and improves query stability and reliability under heavy loads or large datasets.How to use it
Users can control this automatic spilling behavior via the query settingsmax_bytes_ratio_before_external_group_by and max_bytes_ratio_before_external_sort. Adjust these values to set memory usage ratios at which GROUP BY and ORDER BY operations will start writing intermediate data to disk.