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

# short_circuit_function_evaluation_* 会话设置

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

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/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](/docs/zh/reference/functions/regular-functions/conditional-functions#if)、[multiIf](/docs/zh/reference/functions/regular-functions/conditional-functions#multiIf)、[and](/docs/zh/reference/functions/regular-functions/logical-functions#and) 和 [or](/docs/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" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "25.1"},{"label": "1"},{"label": "仅在所有参数均为非 NULL 值的行上执行带有 Nullable 参数的函数"}]}]} />

优化对以下函数的求值：只要任一参数为 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" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "25.1"},{"label": "1"},{"label": "仅对所有参数均为非 NULL 值的行执行带有 Nullable 参数的函数时，NULL 值所占的比例阈值。仅在启用设置 short_circuit_function_evaluation_for_nulls 时生效。"}]}]} />

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