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

These settings are available in [system.settings](https://clickhouse.com/docs/reference/system-tables/settings.md) and are autogenerated from [source](https://github.com/ClickHouse/ClickHouse/blob/master/src/Core/Settings.cpp).

## force\_optimize\_projection

Type

Bool

Default

0

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

When enabled, a projection that can serve the query is used even if it requires reading more marks than the table itself, and the query fails with the `PROJECTION_NOT_USED` error when no projection can be used.

Possible values:

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

## force\_optimize\_projection\_name

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

## force\_optimize\_skip\_unused\_shards

Type

UInt64

Default

0

Enables or disables query execution if [optimize\_skip\_unused\_shards](https://clickhouse.com/docs/reference/settings/session-settings/optimize-skip.md#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.

## force\_optimize\_skip\_unused\_shards\_nesting

Type

UInt64

Default

0

Controls [`force_optimize_skip_unused_shards`](https://clickhouse.com/docs/reference/settings/session-settings/force-optimize#force_optimize_skip_unused_shards) (hence still requires [`force_optimize_skip_unused_shards`](https://clickhouse.com/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.
