> ## Documentation Index
> Fetch the complete documentation index at: https://clickhouse.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# map_buckets_* MergeTree table settings

> ClickHouse MergeTree table settings in the map_buckets_* generated group.

export const SettingsInfoBlock = ({type, default_value, changeable_without_restart}) => {
  return <div className="not-prose" style={{
    display: "flex",
    flexWrap: "wrap",
    alignItems: "baseline",
    columnGap: "0.5rem",
    rowGap: "0.125rem",
    margin: "0.375rem 0",
    fontSize: "0.8125rem",
    lineHeight: "1.125rem"
  }}>
      <div style={{
    fontWeight: 600,
    opacity: 0.72
  }}>Type</div>
      <div style={{
    overflowWrap: "anywhere"
  }}>{type}</div>
      <div style={{
    fontWeight: 600,
    opacity: 0.72,
    marginInlineStart: "0.5rem"
  }}>Default</div>
      <div style={{
    overflowWrap: "anywhere"
  }}>{default_value}</div>
      {changeable_without_restart && <div style={{
    fontWeight: 600,
    opacity: 0.72,
    marginInlineStart: "0.5rem"
  }}>
          Changeable without restart
        </div>}
      {changeable_without_restart && <div style={{
    overflowWrap: "anywhere"
  }}>
          {changeable_without_restart}
        </div>}
    </div>;
};

These settings are available in [system.merge\_tree\_settings](/docs/reference/system-tables/merge_tree_settings) and are autogenerated from ClickHouse source.

<h2 id="map_buckets_coefficient">
  map\_buckets\_coefficient
</h2>

<SettingsInfoBlock type="Float" default_value="1" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.3"},{"label": "1"},{"label": "Add a setting to control the coefficient used in `sqrt` and `linear` strategy for calculating the number of buckets for 'with_buckets' Map serialization"}]}]} />

The coefficient used in `sqrt` and `linear` [map\_buckets\_strategy](/docs/reference/settings/merge-tree-settings/map-buckets#map_buckets_strategy) to calculate the number of buckets from the average map size.
For `sqrt` strategy: `round(map_buckets_coefficient * sqrt(avg_map_size))`.
For `linear` strategy: `round(map_buckets_coefficient * avg_map_size)`.
Ignored when `map_buckets_strategy` is `constant`.

<h2 id="map_buckets_min_avg_size">
  map\_buckets\_min\_avg\_size
</h2>

<SettingsInfoBlock type="UInt64" default_value="32" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.3"},{"label": "32"},{"label": "Add a setting to control the minimum average map size (number of keys per row) required to apply `with_buckets` serialization"}]}]} />

The minimum average map size (number of keys per row) required to apply `with_buckets` serialization.
If the average map size is less than this value, a single bucket is used regardless of other bucket settings.
A value of `0` disables the threshold and always applies the bucketing strategy.
This setting is useful to avoid the overhead of bucketed serialization for small maps where the benefit is negligible.

<h2 id="map_buckets_strategy">
  map\_buckets\_strategy
</h2>

<SettingsInfoBlock type="MergeTreeMapBucketsStrategy" default_value="sqrt" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.3"},{"label": "sqrt"},{"label": "Add a setting to control the strategy for choosing the number of buckets for 'with_buckets' Map serialization"}]}]} />

Controls the strategy for choosing the number of buckets in `with_buckets` `Map` serialization based on the average map size.

Possible values:

* constant — Always use [max\_buckets\_in\_map](/docs/reference/settings/merge-tree-settings/max#max_buckets_in_map) as the number of buckets, regardless of the average map size.
* sqrt — Use `round(map_buckets_coefficient * sqrt(avg_map_size))` as the number of buckets, clamped to `[1, max_buckets_in_map]`.
* linear — Use `round(map_buckets_coefficient * avg_map_size)` as the number of buckets, clamped to `[1, max_buckets_in_map]`.
