mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 08:02:02 +00:00
Merge pull request #45089 from ClickHouse/add-cnf-docs
Add convert_query_to_cnf to docs
This commit is contained in:
commit
b76d0d60db
@ -195,6 +195,75 @@ SELECT * FROM data_01515 WHERE d1 = 0 AND assumeNotNull(d1_null) = 0 SETTINGS fo
|
||||
|
||||
Works with tables in the MergeTree family.
|
||||
|
||||
## convert_query_to_cnf {#convert_query_to_cnf}
|
||||
|
||||
When set to `true`, a `SELECT` query will be converted to conjuctive normal formal (CNF). There are scenarios where rewriting a query in CNF may execute faster (view this [Github issue](https://github.com/ClickHouse/ClickHouse/issues/11749) for an explanation).
|
||||
|
||||
For example, notice how the following `SELECT` query is not modified (the default behavior):
|
||||
|
||||
```sql
|
||||
EXPLAIN SYNTAX
|
||||
SELECT *
|
||||
FROM
|
||||
(
|
||||
SELECT number AS x
|
||||
FROM numbers(20)
|
||||
) AS a
|
||||
WHERE ((x >= 1) AND (x <= 5)) OR ((x >= 10) AND (x <= 15))
|
||||
SETTINGS convert_query_to_cnf = false;
|
||||
```
|
||||
|
||||
The result is:
|
||||
|
||||
```response
|
||||
┌─explain────────────────────────────────────────────────────────┐
|
||||
│ SELECT x │
|
||||
│ FROM │
|
||||
│ ( │
|
||||
│ SELECT number AS x │
|
||||
│ FROM numbers(20) │
|
||||
│ WHERE ((x >= 1) AND (x <= 5)) OR ((x >= 10) AND (x <= 15)) │
|
||||
│ ) AS a │
|
||||
│ WHERE ((x >= 1) AND (x <= 5)) OR ((x >= 10) AND (x <= 15)) │
|
||||
│ SETTINGS convert_query_to_cnf = 0 │
|
||||
└────────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
Let's set `convert_query_to_cnf` to `true` and see what changes:
|
||||
|
||||
```sql
|
||||
EXPLAIN SYNTAX
|
||||
SELECT *
|
||||
FROM
|
||||
(
|
||||
SELECT number AS x
|
||||
FROM numbers(20)
|
||||
) AS a
|
||||
WHERE ((x >= 1) AND (x <= 5)) OR ((x >= 10) AND (x <= 15))
|
||||
SETTINGS convert_query_to_cnf = true;
|
||||
```
|
||||
|
||||
Notice the `WHERE` clause is rewritten in CNF, but the result set is the identical - the Boolean logic is unchanged:
|
||||
|
||||
```response
|
||||
┌─explain───────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
|
||||
│ SELECT x │
|
||||
│ FROM │
|
||||
│ ( │
|
||||
│ SELECT number AS x │
|
||||
│ FROM numbers(20) │
|
||||
│ WHERE ((x <= 15) OR (x <= 5)) AND ((x <= 15) OR (x >= 1)) AND ((x >= 10) OR (x <= 5)) AND ((x >= 10) OR (x >= 1)) │
|
||||
│ ) AS a │
|
||||
│ WHERE ((x >= 10) OR (x >= 1)) AND ((x >= 10) OR (x <= 5)) AND ((x <= 15) OR (x >= 1)) AND ((x <= 15) OR (x <= 5)) │
|
||||
│ SETTINGS convert_query_to_cnf = 1 │
|
||||
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
Possible values: true, false
|
||||
|
||||
Default value: false
|
||||
|
||||
|
||||
## fsync_metadata {#fsync-metadata}
|
||||
|
||||
Enables or disables [fsync](http://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html) when writing `.sql` files. Enabled by default.
|
||||
|
Loading…
Reference in New Issue
Block a user