Repository: ClickHouse/ClickHouse
File: src/Core/Settings.cpp (C++)

Code before:
DECLARE(Bool, merge_tree_use_prefixes_deserialization_thread_pool, true, R"(
Enables usage of the thread pool for parallel prefixes reading in Wide parts in MergeTree. Size of that thread pool is controlled by server setting `max_prefixes_deserialization_thread_pool_size`.
)", 0) \
    DECLARE(Bool, do_not_merge_across_partitions_select_final, false, R"(
Merge parts only in one partition in select final
)", 0) \
    DECLARE(Bool, split_parts_ranges_into_intersecting_and_non_intersecting_final, true, R"(
Split parts ranges into intersecting and non intersecting during FINAL optimization
)", 0) \
    DECLARE(Bool, split_intersecting_parts_ranges_into_layers_final, true, R"(
Split intersecting parts ranges into layers during FINAL optimization
)", 0) \
    \
    DECLARE(UInt64, mysql_max_rows_to_insert, 65536, R"(
The maximum number of rows in MySQL batch insertion of the MySQL storage engine
)", 0) \
    DECLARE(Bool, mysql_map_string_to_text_in_show_columns, true, R"(
When enabled, [String](../../sql-reference/data-types/string.md) ClickHouse data type will be displayed as `TEXT` in [SHOW COLUMNS](../../sql-reference/statements/show.md/#show_columns).

Has an effect only when the connection is made through the MySQL wire protocol.

- 0 - Use `BLOB`.
- 1 - Use `TEXT`.
)", 0) \
    DECLARE(Bool, mysql_map_fixed_string_to_text_in_show_columns, true, R"(
When enabled, [FixedString](../../sql-reference/data-types/fixedstring.md) ClickHouse data type will be displayed as `TEXT` in [SHOW COLUMNS](../../sql-reference/statements/show.md/#show_columns).

Has an effect only when the connection is made through the MySQL wire protocol.

- 0 - Use `BLOB`.
- 1 - Use `TEXT`.
)", 0) \
    \
    DECLARE(UInt64, optimize_min_equality_disjunction_chain_length, 3, R"(
The minimum length of the expression `expr = x1 OR ... expr = xN` for optimization
)", 0) \
    DECLARE(UInt64, optimize_min_inequality_conjunction_chain_length, 3, R"(
The minimum length of the expression `expr <> x1 AND ... expr <> xN` for optimization
)", 0) \
    \
    DECLARE(UInt64, min_bytes_to_use_direct_io, 0, R"(
The minimum data volume required for using direct I/O access to the storage disk.

ClickHouse uses this setting when reading data from tables. If the total storage volume of all the data to be read exceeds `min_bytes_to_use_direct_io` bytes, then ClickHouse reads the data from the storage disk with the `O_DIRECT` option.

Possible values:

- 0 — Direct I/O is disabled.
- Positive integer.
)", 0) \
    DECLARE(UInt64, min_bytes_to_use_mmap_io, 0, R"(

Review comment (performance):
There is already setting `optimize_move_to_prewhere_if_final` which is OFF by default (same reason : final merging should see all versions of a row). Even if the setting is `ON`, only conditions on the sorting key are moved to `PrewhereInfo`. That setting gives enough protection right now, do we need a new setting ? User can definitely pass an explicit `PREWHERE` - where they have considered it to be safe. Do we need this new setting `apply_prewhere_after_final` to protect explicit `PREWHERE` users?

Code after:
DECLARE(Bool, merge_tree_use_prefixes_deserialization_thread_pool, true, R"(
Enables usage of the thread pool for parallel prefixes reading in Wide parts in MergeTree. Size of that thread pool is controlled by server setting `max_prefixes_deserialization_thread_pool_size`.
)", 0) \
    DECLARE(Bool, do_not_merge_across_partitions_select_final, false, R"(
Merge parts only in one partition in select final
)", 0) \
    DECLARE(Bool, split_parts_ranges_into_intersecting_and_non_intersecting_final, true, R"(
Split parts ranges into intersecting and non intersecting during FINAL optimization
)", 0) \
    DECLARE(Bool, split_intersecting_parts_ranges_into_layers_final, true, R"(
Split intersecting parts ranges into layers during FINAL optimization
)", 0) \
    DECLARE(Bool, apply_row_policy_after_final, false, R"(
When enabled, row policies and PREWHERE are applied after FINAL processing for *MergeTree tables. (Especially for ReplacingMergeTree)
When disabled, row policies are applied before FINAL, which can cause different results when the policy
filters out rows that should be used for deduplication in ReplacingMergeTree or similar engines.

If the row policy expression depends only on columns in ORDER BY, it will still be applied before FINAL as an optimization,
since such filtering cannot affect the deduplication result.

Possible values:

- 0 — Row policy and PREWHERE are applied before FINAL (default).
- 1 — Row policy and PREWHERE are applied after FINAL.
)", 0) \
    DECLARE(Bool, apply_prewhere_after_final, false, R"(
When enabled, PREWHERE conditions are applied after FINAL processing for ReplacingMergeTree and similar engines.
This can be useful when PREWHERE references columns that may have different values across duplicate rows,
and you want FINAL to select the winning row before filtering. When disabled, PREWHERE is applied during reading.
Note: If apply_row_level_security_after_final is enabled and row policy uses non-sorting-key columns, PREWHERE will also
be deferred to maintain correct execution order (row policy must be applied before PREWHERE).
)", 0) \
    \
    DECLARE(UInt64, mysql_max_rows_to_insert, 65536, R"(
The maximum number of rows in MySQL batch insertion of the MySQL storage engine
)", 0) \
    DECLARE(Bool, mysql_map_string_to_text_in_show_columns, true, R"(
When enabled, [String](../../sql-reference/data-types/string.md) ClickHouse data type will be displayed as `TEXT` in [SHOW COLUMNS](../../sql-reference/statements/show.md/#show_columns).

Has an effect only when the connection is made through the MySQL wire protocol.

- 0 - Use `BLOB`.
- 1 - Use `TEXT`.
)", 0) \
    DECLARE(Bool, mysql_map_fixed_string_to_text_in_show_columns, true, R"(
When enabled, [FixedString](../../sql-reference/data-types/fixedstring.md) ClickHouse data type will be displayed as `TEXT` in [SHOW COLUMNS](../../sql-reference/statements/show.md/#show_columns).

Has an effect only when the connection is made through the MySQL wire protocol.

- 0 - Use `BLOB`.
- 1 - Use `TEXT`.