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

# materialize_statistics_on_insert_* 세션 설정

> materialize_statistics_on_insert_* 생성 그룹에 속한 ClickHouse 세션 설정입니다.

export const VersionHistory = ({rows = []}) => {
  if (rows.length === 0) {
    return null;
  }
  const headers = ["버전", "기본값", "설명"];
  const border = "1px solid rgba(128, 128, 128, 0.3)";
  const cell = {
    border,
    padding: "0.25rem 0.5rem",
    textAlign: "start",
    verticalAlign: "top"
  };
  return <details className="not-prose" style={{
    border,
    borderRadius: "0.5rem",
    margin: "0.5rem 0",
    padding: "0.5rem 0.75rem",
    fontSize: "0.8125rem",
    lineHeight: "1.125rem"
  }}>
      <summary style={{
    cursor: "pointer",
    fontWeight: 600,
    opacity: 0.72
  }}>
        버전 이력
      </summary>
      <table style={{
    borderCollapse: "collapse",
    width: "100%",
    margin: "0.5rem 0 0"
  }}>
        <thead>
          <tr>
            {headers.map(header => <th key={header} style={{
    ...cell,
    fontWeight: 600,
    opacity: 0.72
  }}>
                {header}
              </th>)}
          </tr>
        </thead>
        <tbody>
          {rows.map((row, row_index) => <tr key={row.id ?? row_index}>
              {(row.items ?? []).map((item, item_index) => <td key={item_index} style={{
    ...cell,
    overflowWrap: "anywhere"
  }}>
                  {item?.label}
                </td>)}
            </tr>)}
        </tbody>
      </table>
    </details>;
};

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/ko/reference/system-tables/settings)에서 확인할 수 있으며, [소스](https://github.com/ClickHouse/ClickHouse/blob/master/src/Core/Settings.cpp)를 기반으로 자동 생성됩니다.

<div id="materialize_statistics_on_insert">
  ## materialize\_statistics\_on\_insert
</div>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.8"},{"label": "1"},{"label": "materialize_statistics_on_insert_max_table_size 미만의 테이블에서는 기본적으로 INSERT 시 컬럼 통계를 구체화하여, 새로 로드된 차원 테이블에서 비용 기반 조인 재정렬이 정확한 추정치를 사용할 수 있도록 합니다."}]}, {"id": "row-2","items": [{"label": "26.4"},{"label": "0"},{"label": "기본적으로 INSERT 시 통계 생성을 비활성화하고, 대신 머지에 의존합니다"}]}, {"id": "row-3","items": [{"label": "24.6"},{"label": "1"},{"label": "삽입 시 통계 구체화를 비활성화할 수 있는 새로운 설정을 추가했습니다"}]}]} />

활성화하면 INSERT 시 통계를 생성하고 삽입합니다. 비활성화하면 통계는 머지 중 또는 명시적인 MATERIALIZE STATISTICS를 통해 생성되고 저장됩니다. 현재 테이블 크기와 기록 중인 블록 크기의 합이 `materialize_statistics_on_insert_max_table_size`를 초과하지 않는 테이블에만 적용됩니다.

<div id="materialize_statistics_on_insert_max_table_size">
  ## materialize\_statistics\_on\_insert\_max\_table\_size
</div>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.8"},{"label": "26843545600"},{"label": "새로운 설정: 현재 크기와 삽입되는 블록 크기의 합이 이 임계값보다 작은 테이블에서만 INSERT 시 컬럼 통계를 구체화합니다. previous_value=0(제한 없음)이므로 26.8 이전 버전과의 `compatibility`를 설정하면 기존 동작이 복원됩니다(이 PR 이전에는 크기 제한이 없었으므로, `materialize_statistics_on_insert`를 명시적으로 다시 활성화한 사용자는 테이블 크기와 관계없이 계속 통계를 구체화합니다)."}]}]} />

디스크에 있는 활성 파트의 현재 총 크기(압축된 크기, 바이트 단위)와 기록할 블록의 비압축 인메모리 크기의 합이 이 값을 초과하지 않는 테이블에서만 INSERT 시 컬럼 통계를 생성하고 저장합니다(`materialize_statistics_on_insert` 참조). 이 규칙은 INSERT 단위가 아니라 기록되는 블록 단위로 적용됩니다. 단일 INSERT는 파티션당 하나의 블록으로 분할되며(스트리밍 삽입의 경우 여러 블록으로 분할됨), 진행 중인 INSERT의 파트는 아직 활성 상태가 아니므로 각 블록은 이미 활성 상태인 파트의 크기를 기준으로 검사됩니다. 따라서 빈 테이블에 단일 대량 로드를 수행하면 전체 크기가 임계값을 초과하더라도 모든 파트의 통계를 생성할 수 있으며, 제한은 이후 삽입부터 적용됩니다. 파트가 기록되기 전에는 압축된 크기를 알 수 없으므로 비압축 블록 크기를 사용하며, 이로 인해 검사는 최대 하나의 블록만큼 의도적으로 보수적으로 수행됩니다. 이렇게 하면 비용 기반 조인 재정렬에 중요한 작은 차원 테이블의 통계를 최신 상태로 유지하면서, 큰 팩트 테이블에서 삽입별 오버헤드를 방지할 수 있습니다(이러한 테이블의 통계는 대신 머지 중에 생성됩니다). `0`은 크기 제한이 없음을 의미합니다.
