mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-26 17:41:59 +00:00
Document the optimize_trivial_count_query setting
This commit is contained in:
parent
23f865c722
commit
eac7074d33
@ -1933,6 +1933,20 @@ Possible values:
|
||||
|
||||
Default value: `0`.
|
||||
|
||||
## optimize_trivial_count_query (optimize-trivial-count-query)
|
||||
|
||||
Enables or disables optimization by metadata for trivial query `SELECT count() FROM table`. If row-level security is set, disable trivial count query optimization.
|
||||
|
||||
Possible values:
|
||||
|
||||
- 0 — Optimization disabled.
|
||||
- 1 — Optimization enabled.
|
||||
|
||||
Default value: `1`.
|
||||
|
||||
**See also:**
|
||||
- [optimize_functions_to_subcolumns](#optimize-trivial-count-query)
|
||||
|
||||
## distributed_replica_error_half_life {#settings-distributed_replica_error_half_life}
|
||||
|
||||
- Type: seconds
|
||||
|
@ -29,7 +29,7 @@ In both cases the type of the returned value is [UInt64](../../../sql-reference/
|
||||
|
||||
ClickHouse supports the `COUNT(DISTINCT ...)` syntax. The behavior of this construction depends on the [count_distinct_implementation](../../../operations/settings/settings.md#settings-count_distinct_implementation) setting. It defines which of the [uniq\*](../../../sql-reference/aggregate-functions/reference/uniq.md#agg_function-uniq) functions is used to perform the operation. The default is the [uniqExact](../../../sql-reference/aggregate-functions/reference/uniqexact.md#agg_function-uniqexact) function.
|
||||
|
||||
The `SELECT count() FROM table` query is not optimized, because the number of entries in the table is not stored separately. It chooses a small column from the table and counts the number of values in it.
|
||||
The `SELECT count() FROM table` query is optimized by default with metadata. If you need to use row-level security, disable [optimize_trivial_count_query](../../../operations/settings/settings.md#optimize_trivial_count_query) setting by set `optimize_trivial_count_query = 0`.
|
||||
|
||||
However `SELECT count(nullable_column) FROM table` query can be optimized by enabling the [optimize_functions_to_subcolumns](../../../operations/settings/settings.md#optimize-functions-to-subcolumns) setting. With `optimize_functions_to_subcolumns = 1` the function reads only [null](../../../sql-reference/data-types/nullable.md#finding-null) subcolumn instead of reading and processing the whole column data. The query `SELECT count(n) FROM table` transforms to `SELECT sum(NOT n.null) FROM table`.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user