Skip to content
ClickHouse Docs
ClickHouse DocsClickHouse Docs

group_by_* session settings

These settings are available in system.settings and are autogenerated from source.

group_by_overflow_mode

Type
OverflowModeGroupBy
Default
throw

Sets what happens when the number of unique keys for aggregation exceeds the limit:

  • throw: throw an exception
  • break: stop executing the query and return the partial result
  • any: continue aggregation for the keys that got into the set, but do not add new keys to the set.

Using the ‘any’ value lets you run an approximation of GROUP BY. The quality of this approximation depends on the statistical nature of the data.

group_by_top_k_optimization_observation_rows

Experimental feature
Type
UInt64
Default
65536
Version history
VersionDefault valueComment
26.865536New experimental setting: rows each aggregation stream observes before declaring a full top-K heap that never rejected anything pure overhead and freezing it.

For enable_group_by_top_k_optimization: the number of rows each aggregation stream observes before freezing a full top-K heap that skipped less than 10% of input rows and evicted fewer keys than its capacity. A frozen heap means aggregation continues as if the optimization were disabled.

The effective window is at least twice the heap’s reserved size, so a heap always gets a chance to fill before being judged. 0 disables this freeze (the heap still freezes when a boundary tie-set overgrows it).

This has no effect on GROUP BY keys LIMIT K queries without ORDER BY, where the freeze is always disabled: that shape’s plan contains a synthesized sort that only pays off while the heap bounds the hash table, so freezing the heap would leave a plan slower than the un-optimized one.

group_by_two_level_threshold

Type
UInt64
Default
100000

From what number of keys, a two-level aggregation starts. 0 - the threshold is not set.

group_by_two_level_threshold_bytes

Type
UInt64
Default
50000000

From what size of the aggregation state in bytes, a two-level aggregation begins to be used. 0 - the threshold is not set. Two-level aggregation is used when at least one of the thresholds is triggered.

group_by_use_nulls

Type
Bool
Default
0

Changes the way the GROUP BY clause treats the types of aggregation keys. When the ROLLUP, CUBE, or GROUPING SETS specifiers are used, some aggregation keys may not be used to produce some result rows. Columns for these keys are filled with either default value or NULL in corresponding rows depending on this setting.

Possible values:

  • 0 — The default value for the aggregation key type is used to produce missing values.
  • 1 — ClickHouse executes GROUP BY the same way as the SQL standard says. The types of aggregation keys are converted to Nullable. Columns for corresponding aggregation keys are filled with NULL for rows that didn’t use it.

See also:

Navigation