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

# force_optimize_* session settings

> ClickHouse session settings in the force_optimize_* 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.settings](/docs/reference/system-tables/settings) and are autogenerated from [source](https://github.com/ClickHouse/ClickHouse/blob/master/src/Core/Settings.cpp).

<h2 id="force_optimize_projection">
  force\_optimize\_projection
</h2>

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

Enables or disables the obligatory use of [projections](/docs/reference/engines/table-engines/mergetree-family/mergetree#projections) in `SELECT` queries, when projection optimization is enabled (see [optimize\_use\_projections](/docs/reference/settings/session-settings/optimize-use#optimize_use_projections) setting).

Possible values:

* 0 — Projection optimization is not obligatory.
* 1 — Projection optimization is obligatory.

<h2 id="force_optimize_projection_name">
  force\_optimize\_projection\_name
</h2>

If it is set to a non-empty string, check that this projection is used in the query at least once.

Possible values:

* string: name of projection that used in a query

<h2 id="force_optimize_skip_unused_shards">
  force\_optimize\_skip\_unused\_shards
</h2>

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

Enables or disables query execution if [optimize\_skip\_unused\_shards](/docs/reference/settings/session-settings/optimize-skip#optimize_skip_unused_shards) is enabled and skipping of unused shards is not possible. If the skipping is not possible and the setting is enabled, an exception will be thrown.

Possible values:

* 0 — Disabled. ClickHouse does not throw an exception.
* 1 — Enabled. Query execution is disabled only if the table has a sharding key.
* 2 — Enabled. Query execution is disabled regardless of whether a sharding key is defined for the table.

<h2 id="force_optimize_skip_unused_shards_nesting">
  force\_optimize\_skip\_unused\_shards\_nesting
</h2>

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

Controls [`force_optimize_skip_unused_shards`](/docs/reference/settings/session-settings/force-optimize#force_optimize_skip_unused_shards) (hence still requires [`force_optimize_skip_unused_shards`](/docs/reference/settings/session-settings/force-optimize#force_optimize_skip_unused_shards)) depends on the nesting level of the distributed query (case when you have `Distributed` table that look into another `Distributed` table).

Possible values:

* 0 - Disabled, `force_optimize_skip_unused_shards` works always.
* 1 — Enables `force_optimize_skip_unused_shards` only for the first level.
* 2 — Enables `force_optimize_skip_unused_shards` up to the second level.
