Skip to main content
These settings are available in system.settings and are autogenerated from source.

optimize_aggregation_in_order

Enables GROUP BY optimization in SELECT queries for aggregating data in corresponding order in MergeTree tables. Possible values:
  • 0 — GROUP BY optimization is disabled.
  • 1 — GROUP BY optimization is enabled.
See Also

optimize_aggregation_in_order_limit

When enabled and aggregation in order is active, pushes LIMIT into the aggregation step to enable early termination after producing enough groups. This reduces the amount of data read when ORDER BY matches the GROUP BY key prefix. May reduce the value reported by rows_before_limit_at_least; use exact_rows_before_limit if exact counts are needed.
Last modified on July 23, 2026