> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-postgresql-tls-support.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# short_circuit_function_evaluation_* 会话设置

> ClickHouse 中 short_circuit_function_evaluation_* 生成组的会话设置。

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](/zh/reference/system-tables/settings) 中查看，并由 [源代码](https://github.com/ClickHouse/ClickHouse/blob/master/src/Core/Settings.cpp) 自动生成。

<div id="short_circuit_function_evaluation">
  ## short\_circuit\_function\_evaluation
</div>

<SettingsInfoBlock type="ShortCircuitFunctionEvaluation" default_value="enable" />

允许按照[短路求值](https://en.wikipedia.org/wiki/Short-circuit_evaluation)机制计算 [if](/zh/reference/functions/regular-functions/conditional-functions#if)、[multiIf](/zh/reference/functions/regular-functions/conditional-functions#multiIf)、[and](/zh/reference/functions/regular-functions/logical-functions#and) 和 [or](/zh/reference/functions/regular-functions/logical-functions#or) 函数。这有助于优化这些函数中复杂表达式的执行，并防止可能出现的异常 (例如在不应发生时出现除零) 。

Possible values:

* `enable` — 对适合使用短路求值的函数启用短路函数求值 (可能抛出异常或计算开销较大) 。
* `force_enable` — 对所有函数启用短路函数求值。
* `disable` — 禁用短路函数求值。

<div id="short_circuit_function_evaluation_for_nulls">
  ## short\_circuit\_function\_evaluation\_for\_nulls
</div>

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

优化对以下函数的求值：只要任一参数为 NULL，就返回 NULL 的函数。当函数参数中的 NULL 值占比超过 short\_circuit\_function\_evaluation\_for\_nulls\_threshold 时，系统会跳过按行求值。相反，它会直接为所有行返回 NULL，从而避免不必要的计算。

<div id="short_circuit_function_evaluation_for_nulls_threshold">
  ## short\_circuit\_function\_evaluation\_for\_nulls\_threshold
</div>

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

仅对所有参数均为非 NULL 值的行执行带有 Nullable 参数的函数时，NULL 值所占的比例阈值。仅在启用设置 short\_circuit\_function\_evaluation\_for\_nulls 时生效。
当包含 NULL 值的行占总行数的比例超过此阈值时，这些包含 NULL 值的行将不再参与计算。
