> ## 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.

# optimize_aggregation_in_order_* セッション設定

> optimize_aggregation_in_order_* の自動生成グループに含まれる ClickHouse のセッション設定。

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
  }}>型</div>
      <div style={{
    overflowWrap: "anywhere"
  }}>{type}</div>
      <div style={{
    fontWeight: 600,
    opacity: 0.72,
    marginInlineStart: "0.5rem"
  }}>デフォルト値</div>
      <div style={{
    overflowWrap: "anywhere"
  }}>{default_value}</div>
      {changeable_without_restart && <div style={{
    fontWeight: 600,
    opacity: 0.72,
    marginInlineStart: "0.5rem"
  }}>
          再起動せずに変更可能
        </div>}
      {changeable_without_restart && <div style={{
    overflowWrap: "anywhere"
  }}>
          {changeable_without_restart}
        </div>}
    </div>;
};

これらの設定は [system.settings](/docs/ja/reference/system-tables/settings) で参照でき、[ソース](https://github.com/ClickHouse/ClickHouse/blob/master/src/Core/Settings.cpp) から自動生成されています。

<div id="optimize_aggregation_in_order">
  ## optimize\_aggregation\_in\_order
</div>

<SettingsInfoBlock type="Bool" default_value="0" />

[MergeTree](/docs/ja/reference/engines/table-engines/mergetree-family/mergetree) テーブルにおいて、対応する順序でデータを集約する [SELECT](/docs/ja/reference/statements/select/index) クエリでの [GROUP BY](/docs/ja/reference/statements/select/group-by) 最適化を有効にします。

設定可能な値:

* 0 — `GROUP BY` 最適化は無効です。
* 1 — `GROUP BY` 最適化は有効です。

**関連項目**

* [GROUP BY optimization](/docs/ja/reference/statements/select/group-by#group-by-optimization-depending-on-table-sorting-key)

<div id="optimize_aggregation_in_order_limit">
  ## optimize\_aggregation\_in\_order\_limit
</div>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.7"},{"label": "1"},{"label": "`ORDER BY` が `GROUP BY` のソート記述のプレフィックスである場合に、十分な数のグループが生成された時点で早期終了できるよう、`LIMIT` を順序付き集約に適用する新しい設定。"}]}]} />

有効時に順序付き集約がアクティブであれば、十分な数のグループが生成された時点で早期終了できるよう、`LIMIT` を集約ステップに適用します。これにより、`ORDER BY` が `GROUP BY` キーのプレフィックスに一致する場合、読み取るデータ量を削減できます。`rows_before_limit_at_least` で報告される値が少なくなる可能性があります。正確な件数が必要な場合は、`exact_rows_before_limit` を使用してください。
