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

# query_plan_* session settings

> ClickHouse session settings in the query_plan_* 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>;
};

export const ExperimentalBadge = () => {
  return <div className="experimentalBadge">
            <div className="experimentalIcon">
            <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
                <path strokeWidth="1.25" d="M5.5 2H10.5" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" />
                <path strokeWidth="1.25" d="M9.50015 2V6.19625L13.4283 12.7425C13.4738 12.8183 13.4985 12.9049 13.4996 12.9934C13.5008 13.0818 13.4785 13.169 13.435 13.246C13.3914 13.323 13.3283 13.3871 13.2519 13.4317C13.1755 13.4764 13.0886 13.4999 13.0002 13.5H3.00015C2.91164 13.5 2.8247 13.4766 2.74822 13.432C2.67174 13.3874 2.60847 13.3233 2.56487 13.2463C2.52126 13.1693 2.49889 13.082 2.50004 12.9935C2.50119 12.905 2.52582 12.8184 2.5714 12.7425L6.50015 6.19625V2" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" />
                <path strokeWidth="1.25" d="M4.47656 9.56754C5.30344 9.41254 6.47656 9.47942 7.99969 10.25C10.0153 11.2707 11.4216 11.0569 12.2184 10.7282" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" />
            </svg>
        </div>
            Experimental feature. <u><a href="/docs/docs/beta-and-experimental-features#experimental-features">Learn more.</a></u>
        </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="query_plan_aggregation_in_order">
  query\_plan\_aggregation\_in\_order
</h2>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "22.12"},{"label": "1"},{"label": "Enable some refactoring around query plan"}]}]} />

Toggles the aggregation in-order query-plan-level optimization.
Only takes effect if setting [`query_plan_enable_optimizations`](/docs/reference/settings/session-settings/query-plan#query_plan_enable_optimizations) is 1.

<Note>
  This is an expert-level setting which should only be used for debugging by developers. The setting may change in future in backward-incompatible ways or be removed.
</Note>

Possible values:

* 0 - Disable
* 1 - Enable

<h2 id="query_plan_convert_any_join_to_semi_or_anti_join">
  query\_plan\_convert\_any\_join\_to\_semi\_or\_anti\_join
</h2>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "25.9"},{"label": "1"},{"label": "New setting."}]}]} />

Allow to convert ANY JOIN to SEMI or ANTI JOIN if filter after JOIN always evaluates to false for not-matched or matched rows

<h2 id="query_plan_convert_join_to_in">
  query\_plan\_convert\_join\_to\_in
</h2>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "25.4"},{"label": "0"},{"label": "New setting"}]}]} />

Allow to convert `JOIN` to subquery with `IN` if output columns tied to only left table. May cause wrong results with non-ANY JOINs (e.g. ALL JOINs which is the default).

<h2 id="query_plan_convert_outer_join_to_inner_join">
  query\_plan\_convert\_outer\_join\_to\_inner\_join
</h2>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "24.4"},{"label": "1"},{"label": "Allow to convert OUTER JOIN to INNER JOIN if filter after JOIN always filters default values"}]}]} />

Allow to convert `OUTER JOIN` to `INNER JOIN` if filter after `JOIN` always filters default values

<h2 id="query_plan_direct_read_from_text_index">
  query\_plan\_direct\_read\_from\_text\_index
</h2>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.2"},{"label": "1"},{"label": "The text index is now GA"}]}, {"id": "row-2","items": [{"label": "25.9"},{"label": "1"},{"label": "New setting."}]}]} />

Allow to perform full text search filtering using only the inverted text index in query plan.

<h2 id="query_plan_display_internal_aliases">
  query\_plan\_display\_internal\_aliases
</h2>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "25.9"},{"label": "0"},{"label": "New setting"}]}]} />

Show internal aliases (such as \_\_table1) in EXPLAIN PLAN instead of those specified in the original query.

<h2 id="query_plan_enable_multithreading_after_window_functions">
  query\_plan\_enable\_multithreading\_after\_window\_functions
</h2>

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

Enable multithreading after evaluating window functions to allow parallel stream processing

<h2 id="query_plan_enable_optimizations">
  query\_plan\_enable\_optimizations
</h2>

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

Toggles query optimization at the query plan level.

<Note>
  This is an expert-level setting which should only be used for debugging by developers. The setting may change in future in backward-incompatible ways or be removed.
</Note>

Possible values:

* 0 - Disable all optimizations at the query plan level
* 1 - Enable optimizations at the query plan level (but individual optimizations may still be disabled via their individual settings)

<h2 id="query_plan_execute_functions_after_sorting">
  query\_plan\_execute\_functions\_after\_sorting
</h2>

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

Toggles a query-plan-level optimization which moves expressions after sorting steps.
Only takes effect if setting [`query_plan_enable_optimizations`](/docs/reference/settings/session-settings/query-plan#query_plan_enable_optimizations) is 1.

<Note>
  This is an expert-level setting which should only be used for debugging by developers. The setting may change in future in backward-incompatible ways or be removed.
</Note>

Possible values:

* 0 - Disable
* 1 - Enable

<h2 id="query_plan_filter_push_down">
  query\_plan\_filter\_push\_down
</h2>

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

Toggles a query-plan-level optimization which moves filters down in the execution plan.
Only takes effect if setting [query\_plan\_enable\_optimizations](/docs/reference/settings/session-settings/query-plan#query_plan_enable_optimizations) is 1.

<Note>
  This is an expert-level setting which should only be used for debugging by developers. The setting may change in future in backward-incompatible ways or be removed.
</Note>

Possible values:

* 0 - Disable
* 1 - Enable

<h2 id="query_plan_join_shard_by_pk_ranges">
  query\_plan\_join\_shard\_by\_pk\_ranges
</h2>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "25.4"},{"label": "0"},{"label": "New setting"}]}]} />

Apply sharding for JOIN if join keys contain a prefix of PRIMARY KEY for both tables. Supported for hash, parallel\_hash and full\_sorting\_merge algorithms. Usually does not speed up queries but may lower memory consumption.

<h2 id="query_plan_join_swap_table">
  query\_plan\_join\_swap\_table
</h2>

<SettingsInfoBlock type="BoolAuto" default_value="auto" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "24.12"},{"label": "auto"},{"label": "New setting. Right table was always chosen before."}]}]} />

Determine which side of the join should be the build table (also called inner, the one inserted into the hash table for a hash join) in the query plan. This setting is supported only for `ALL` join strictness with the `JOIN ON` clause. Possible values are:

* 'auto': Let the planner decide which table to use as the build table.
* 'false': Never swap tables (the right table is the build table).
* 'true': Always swap tables (the left table is the build table).

<h2 id="query_plan_lift_up_array_join">
  query\_plan\_lift\_up\_array\_join
</h2>

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

Toggles a query-plan-level optimization which moves ARRAY JOINs up in the execution plan.
Only takes effect if setting [query\_plan\_enable\_optimizations](/docs/reference/settings/session-settings/query-plan#query_plan_enable_optimizations) is 1.

<Note>
  This is an expert-level setting which should only be used for debugging by developers. The setting may change in future in backward-incompatible ways or be removed.
</Note>

Possible values:

* 0 - Disable
* 1 - Enable

<h2 id="query_plan_lift_up_union">
  query\_plan\_lift\_up\_union
</h2>

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

Toggles a query-plan-level optimization which moves larger subtrees of the query plan into union to enable further optimizations.
Only takes effect if setting [`query_plan_enable_optimizations`](/docs/reference/settings/session-settings/query-plan#query_plan_enable_optimizations) is 1.

<Note>
  This is an expert-level setting which should only be used for debugging by developers. The setting may change in future in backward-incompatible ways or be removed.
</Note>

Possible values:

* 0 - Disable
* 1 - Enable

<h2 id="query_plan_max_limit_for_join_lazy_indexing">
  query\_plan\_max\_limit\_for\_join\_lazy\_indexing
</h2>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.6"},{"label": "1000"},{"label": "Added new setting to control maximum limit value that allows to use query plan for lazy join indexing optimization. If zero, there is no limit"}]}]} />

Control maximum limit value that allows to use query plan for lazy indexing optimization in JOIN. If zero, there is no limit.

<h2 id="query_plan_max_limit_for_lazy_materialization">
  query\_plan\_max\_limit\_for\_lazy\_materialization
</h2>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "25.4"},{"label": "10"},{"label": "Added new setting to control maximum limit value that allows to use query plan for lazy materialization optimisation. If zero, there is no limit"}]}, {"id": "row-2","items": [{"label": "25.12"},{"label": "10000"},{"label": "Increase the limit after performance improvement"}]}, {"id": "row-3","items": [{"label": "25.11"},{"label": "100"},{"label": "More optimal"}]}]} />

Control maximum limit value that allows to use query plan for lazy materialization optimization. If zero, there is no limit.

<h2 id="query_plan_max_limit_for_top_k_optimization">
  query\_plan\_max\_limit\_for\_top\_k\_optimization
</h2>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "25.12"},{"label": "1000"},{"label": "New setting."}]}]} />

Control maximum limit value that allows to evaluate query plan for TopK optimization by using minmax skip index and dynamic threshold filtering. If zero, there is no limit.

<h2 id="query_plan_max_optimizations_to_apply">
  query\_plan\_max\_optimizations\_to\_apply
</h2>

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

Limits the total number of optimizations applied to query plan, see setting [query\_plan\_enable\_optimizations](/docs/reference/settings/session-settings/query-plan#query_plan_enable_optimizations).
Useful to avoid long optimization times for complex queries.
In the EXPLAIN PLAN query, stop applying optimizations after this limit is reached and return the plan as is.
For regular query execution if the actual number of optimizations exceeds this setting, an exception is thrown.

<Note>
  This is an expert-level setting which should only be used for debugging by developers. The setting may change in future in backward-incompatible ways or be removed.
</Note>

<h2 id="query_plan_max_set_size_for_projection_match">
  query\_plan\_max\_set\_size\_for\_projection\_match
</h2>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.6"},{"label": "10000"},{"label": "Added new setting that bounds the cost of content-hashing IN-clause sets in the projection matcher (today: aggregate projection). Sets larger than the limit are treated as non-matching. Zero disables content-hash comparison entirely (compatibility value: projection match never succeeds for nodes with IN-sets)."}]}]} />

Maximum number of rows in an `IN`-clause set for which the projection matcher computes and compares content hashes when deciding whether two sets are equal. Sets larger than this are treated as non-matching and skip the projection. Zero disables content-hash comparison entirely: a projection match never succeeds for nodes containing `IN`-clause sets.

Used by the aggregate projection matcher (and any future projection matcher that needs to compare `IN`-clause sets). Computing the content hash is `O(N log N)` in the number of set elements; this setting bounds the cost paid during planning when many `IN`-clauses appear in the query or the projection.

<h2 id="query_plan_max_step_description_length">
  query\_plan\_max\_step\_description\_length
</h2>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "25.9"},{"label": "500"},{"label": "New setting"}]}]} />

Maximum length of step description in EXPLAIN PLAN.

<h2 id="query_plan_merge_expression_into_join">
  query\_plan\_merge\_expression\_into\_join
</h2>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.7"},{"label": "1"},{"label": "New setting. Allow to merge Expression step into JOIN step during join reordering optimization."}]}]} />

Allow to merge expressions into JOIN step during join reordering optimization.

<h2 id="query_plan_merge_expressions">
  query\_plan\_merge\_expressions
</h2>

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

Toggles a query-plan-level optimization which merges consecutive filters.
Only takes effect if setting [query\_plan\_enable\_optimizations](/docs/reference/settings/session-settings/query-plan#query_plan_enable_optimizations) is 1.

<Note>
  This is an expert-level setting which should only be used for debugging by developers. The setting may change in future in backward-incompatible ways or be removed.
</Note>

Possible values:

* 0 - Disable
* 1 - Enable

<h2 id="query_plan_merge_filter_into_join_condition">
  query\_plan\_merge\_filter\_into\_join\_condition
</h2>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "25.4"},{"label": "1"},{"label": "Added new setting to merge filter into join condition"}]}]} />

Allow to merge filter into `JOIN` condition and convert `CROSS JOIN` to `INNER`.

<h2 id="query_plan_merge_filters">
  query\_plan\_merge\_filters
</h2>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "24.7"},{"label": "0"},{"label": "Allow to merge filters in the query plan"}]}, {"id": "row-2","items": [{"label": "24.11"},{"label": "1"},{"label": "Allow to merge filters in the query plan. This is required to properly support filter-push-down with the analyzer."}]}]} />

Allow to merge filters in the query plan.

<h2 id="query_plan_min_columns_for_join_lazy_indexing">
  query\_plan\_min\_columns\_for\_join\_lazy\_indexing
</h2>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.6"},{"label": "3"},{"label": "Control the minimum number of payload columns from the left side required for enabling lazy indexing optimization in JOIN"}]}]} />

Control the minimum number of payload columns from the left side required for enabling lazy indexing optimization in JOIN. 0 means the optimization is disabled.

<h2 id="query_plan_optimize_join_order_algorithm">
  query\_plan\_optimize\_join\_order\_algorithm
</h2>

<ExperimentalBadge />

<SettingsInfoBlock type="JoinOrderAlgorithm" default_value="greedy" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "25.12"},{"label": "greedy"},{"label": "New experimental setting."}]}]} />

Specifies which JOIN order algorithms to attempt during query plan optimization. The following algorithms are available:

* 'greedy' - basic greedy algorithm - works fast but might not produce the best join order
* 'dpsize' - implements DPsize algorithm currently only for Inner joins - considers all possible join orders and finds the most optimal one but might be slow for queries with many tables and join predicates.
* 'dpsub' - implements DPsub algorithm which supports both inner and non-inner joins - considers all possible join orders and finds the most optimal one but might be slow for queries with many tables and join predicates.
* 'dphyp' - implements DPhyp (Dynamic Programming via Hypergraph Partitioning) algorithm currently only for inner joins - explores the same search space as `dpsize` but enumerates only connected subgraph pairs, which generates fewer intermediate joins on sparse join graphs, at the cost of not considering cross products
  Multiple algorithms can be specified as a comma-separated list, e.g. `dphyp,greedy`. They are tried in order; if an algorithm cannot handle the query (e.g. due to outer joins or disconnected components), the next one is used as a fallback.

<h2 id="query_plan_optimize_join_order_limit">
  query\_plan\_optimize\_join\_order\_limit
</h2>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "25.9"},{"label": "1"},{"label": "New setting"}]}, {"id": "row-2","items": [{"label": "25.12"},{"label": "10"},{"label": "Allow JOIN reordering with more tables by default"}]}]} />

Optimize the order of joins within the same subquery. Currently only supported for very limited cases.
Value is the maximum number of tables to optimize.

<h2 id="query_plan_optimize_join_order_max_searched_plans">
  query\_plan\_optimize\_join\_order\_max\_searched\_plans
</h2>

<ExperimentalBadge />

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.6"},{"label": "100000"},{"label": "New setting to bound the number of partial plans the join order optimizer enumerates before falling back to the next algorithm."}]}]} />

Maximum number of partial plans the join order optimizer may enumerate before giving up and falling back to the next algorithm in `query_plan_optimize_join_order_algorithm`.
This bounds optimization time deterministically (independent of wall-clock) on dense join graphs such as cliques or stars, where the search space grows exponentially.
Set to 0 to disable the limit. Has no effect on the default `query_plan_optimize_join_order_limit`, where the search always stays well below this bound.

<h2 id="query_plan_optimize_join_order_randomize">
  query\_plan\_optimize\_join\_order\_randomize
</h2>

<ExperimentalBadge />

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.4"},{"label": "0"},{"label": "New setting to randomize join order statistics for testing."}]}]} />

When non-zero, the join order optimizer uses randomly generated cardinalities and NDVs instead of real statistics.
When set to 1, a random seed is generated, when set to a value > 1, that value is used as the seed directly.
This is intended for testing to find errors caused by different join orderings.

<h2 id="query_plan_optimize_lazy_final">
  query\_plan\_optimize\_lazy\_final
</h2>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.4"},{"label": "0"},{"label": "New setting to optimize reading with FINAL from ReplacingMergeTree using set-based index analysis"}]}]} />

Optimize reading with FINAL from ReplacingMergeTree by building a set of primary keys and using it for index analysis.

<h2 id="query_plan_optimize_lazy_materialization">
  query\_plan\_optimize\_lazy\_materialization
</h2>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "25.4"},{"label": "1"},{"label": "Added new setting to use query plan for lazy materialization optimisation"}]}]} />

Use query plan for lazy materialization optimization.

<h2 id="query_plan_optimize_prewhere">
  query\_plan\_optimize\_prewhere
</h2>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "24.2"},{"label": "1"},{"label": "Allow to push down filter to PREWHERE expression for supported storages"}]}]} />

Allow to push down filter to PREWHERE expression for supported storages

<h2 id="query_plan_push_down_limit">
  query\_plan\_push\_down\_limit
</h2>

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

Toggles a query-plan-level optimization which moves LIMITs down in the execution plan.
Only takes effect if setting [query\_plan\_enable\_optimizations](/docs/reference/settings/session-settings/query-plan#query_plan_enable_optimizations) is 1.

<Note>
  This is an expert-level setting which should only be used for debugging by developers. The setting may change in future in backward-incompatible ways or be removed.
</Note>

Possible values:

* 0 - Disable
* 1 - Enable

<h2 id="query_plan_push_limit_by_into_sort">
  query\_plan\_push\_limit\_by\_into\_sort
</h2>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.6"},{"label": "1"},{"label": "New setting that pushes a per-stream LIMIT BY into the sort pipeline when LIMIT BY's columns are a prefix of ORDER BY, reducing rows flowing through the final merge."}]}]} />

Toggles a query-plan-level optimization for `ORDER BY ... LIMIT BY` queries. When `LIMIT BY` columns are a prefix of the `ORDER BY` clause, each parallel sorted stream applies `LIMIT BY` before the streams are merged into one, reducing rows processed by the final merge and later pipeline stages. Speeds up queries where `LIMIT BY` discards a large fraction of rows.

Only takes effect if setting [query\_plan\_enable\_optimizations](/docs/reference/settings/session-settings/query-plan#query_plan_enable_optimizations) is 1.

Possible values:

* 0 - Disable
* 1 - Enable

<h2 id="query_plan_read_in_order">
  query\_plan\_read\_in\_order
</h2>

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

Toggles the read in-order optimization query-plan-level optimization.
Only takes effect if setting [`query_plan_enable_optimizations`](/docs/reference/settings/session-settings/query-plan#query_plan_enable_optimizations) is 1.

<Note>
  This is an expert-level setting which should only be used for debugging by developers. The setting may change in future in backward-incompatible ways or be removed.
</Note>

Possible values:

* 0 - Disable
* 1 - Enable

<h2 id="query_plan_read_in_order_through_join">
  query\_plan\_read\_in\_order\_through\_join
</h2>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "25.12"},{"label": "1"},{"label": "New setting"}]}]} />

Keep reading in order from the left table in JOIN operations, which can be utilized by subsequent steps.

<h2 id="query_plan_remove_redundant_distinct">
  query\_plan\_remove\_redundant\_distinct
</h2>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "23.2"},{"label": "1"},{"label": "Remove redundant Distinct step in query plan"}]}]} />

Toggles a query-plan-level optimization which removes redundant DISTINCT steps.
Only takes effect if setting [`query_plan_enable_optimizations`](/docs/reference/settings/session-settings/query-plan#query_plan_enable_optimizations) is 1.

<Note>
  This is an expert-level setting which should only be used for debugging by developers. The setting may change in future in backward-incompatible ways or be removed.
</Note>

Possible values:

* 0 - Disable
* 1 - Enable

<h2 id="query_plan_remove_redundant_sorting">
  query\_plan\_remove\_redundant\_sorting
</h2>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "23.1"},{"label": "1"},{"label": "Remove redundant sorting in query plan. For example, sorting steps related to ORDER BY clauses in subqueries"}]}]} />

Toggles a query-plan-level optimization which removes redundant sorting steps, e.g. in subqueries.
Only takes effect if setting [`query_plan_enable_optimizations`](/docs/reference/settings/session-settings/query-plan#query_plan_enable_optimizations) is 1.

<Note>
  This is an expert-level setting which should only be used for debugging by developers. The setting may change in future in backward-incompatible ways or be removed.
</Note>

Possible values:

* 0 - Disable
* 1 - Enable

<h2 id="query_plan_remove_unused_columns">
  query\_plan\_remove\_unused\_columns
</h2>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "25.12"},{"label": "1"},{"label": "New setting. Add optimization to remove unused columns in query plan."}]}]} />

Toggles a query-plan-level optimization which tries to remove unused columns (both input and output columns) from query plan steps.
Only takes effect if setting [query\_plan\_enable\_optimizations](/docs/reference/settings/session-settings/query-plan#query_plan_enable_optimizations) is 1.

<Note>
  This is an expert-level setting which should only be used for debugging by developers. The setting may change in future in backward-incompatible ways or be removed.
</Note>

Possible values:

* 0 - Disable
* 1 - Enable

<h2 id="query_plan_reuse_storage_ordering_for_window_functions">
  query\_plan\_reuse\_storage\_ordering\_for\_window\_functions
</h2>

**Aliases**: `optimize_read_in_window_order`

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.1"},{"label": "0"},{"label": "Disable this logic by default."}]}]} />

Toggles a query-plan-level optimization which uses storage sorting when sorting for window functions.
Only takes effect if setting [`query_plan_enable_optimizations`](/docs/reference/settings/session-settings/query-plan#query_plan_enable_optimizations) is 1.

<Note>
  This is an expert-level setting which should only be used for debugging by developers. The setting may change in future in backward-incompatible ways or be removed.
</Note>

Possible values:

* 0 - Disable
* 1 - Enable

<h2 id="query_plan_split_filter">
  query\_plan\_split\_filter
</h2>

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

<Note>
  This is an expert-level setting which should only be used for debugging by developers. The setting may change in future in backward-incompatible ways or be removed.
</Note>

Toggles a query-plan-level optimization which splits filters into expressions.
Only takes effect if setting [query\_plan\_enable\_optimizations](/docs/reference/settings/session-settings/query-plan#query_plan_enable_optimizations) is 1.

Possible values:

* 0 - Disable
* 1 - Enable

<h2 id="query_plan_text_index_add_hint">
  query\_plan\_text\_index\_add\_hint
</h2>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "25.12"},{"label": "1"},{"label": "New setting"}]}]} />

Allow to add hint (additional predicate) for filtering built from the inverted text index in query plan.

<h2 id="query_plan_top_k_through_join">
  query\_plan\_top\_k\_through\_join
</h2>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.5"},{"label": "1"},{"label": "New setting to enable a query-plan-level optimization that pushes ORDER BY ... LIMIT n through a LEFT\/RIGHT join when the sort key only references the preserved side."}]}]} />

Toggles a query-plan-level optimization which pushes `ORDER BY ... LIMIT n` down through a join when the sort key only references columns from the side preserved by the join (LEFT/RIGHT). Restricts how many rows the preserved-side input must produce before joining.
Only takes effect if setting [query\_plan\_enable\_optimizations](/docs/reference/settings/session-settings/query-plan#query_plan_enable_optimizations) is 1.

Possible values:

* 0 - Disable
* 1 - Enable

<h2 id="query_plan_try_use_vector_search">
  query\_plan\_try\_use\_vector\_search
</h2>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "25.1"},{"label": "1"},{"label": "New setting."}]}]} />

Toggles a query-plan-level optimization which tries to use the vector similarity index.
Only takes effect if setting [`query_plan_enable_optimizations`](/docs/reference/settings/session-settings/query-plan#query_plan_enable_optimizations) is 1.

<Note>
  This is an expert-level setting which should only be used for debugging by developers. The setting may change in future in backward-incompatible ways or be removed.
</Note>

Possible values:

* 0 - Disable
* 1 - Enable
