Merge pull request #43451 from ClickHouse/explain-query-tree-run

Set run_passes to 1 by default
This commit is contained in:
Maksim Kita 2022-11-23 01:30:49 +03:00 committed by GitHub
commit db1b971643
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 5 deletions

View File

@ -47,6 +47,7 @@ Union
- `AST` — Abstract syntax tree.
- `SYNTAX` — Query text after AST-level optimizations.
- `QUERY TREE` — Query tree after Query Tree level optimizations.
- `PLAN` — Query execution plan.
- `PIPELINE` — Query execution pipeline.
@ -110,6 +111,32 @@ FROM
CROSS JOIN system.numbers AS c
```
### EXPLAIN QUERY TREE
Settings:
- `run_passes` — Run all query tree passes before dumping the query tree. Defaul: `1`.
- `dump_passes` — Dump information about used passes before dumping the query tree. Default: `0`.
- `passes` — Specifies how many passes to run. If set to `-1`, runs all the passes. Default: `-1`.
Example:
```sql
EXPLAIN QUERY TREE SELECT id, value FROM test_table;
```
```
QUERY id: 0
PROJECTION COLUMNS
id UInt64
value String
PROJECTION
LIST id: 1, nodes: 2
COLUMN id: 2, column_name: id, result_type: UInt64, source_id: 3
COLUMN id: 4, column_name: value, result_type: String, source_id: 3
JOIN TREE
TABLE id: 3, table_name: default.test_table
```
### EXPLAIN PLAN
Dump query plan steps.

View File

@ -165,7 +165,7 @@ struct QueryASTSettings
struct QueryTreeSettings
{
bool run_passes = false;
bool run_passes = true;
bool dump_passes = false;
bool dump_ast = false;
Int64 passes = -1;

View File

@ -1,6 +1,6 @@
SET allow_experimental_analyzer = 1;
EXPLAIN QUERY TREE SELECT 1;
EXPLAIN QUERY TREE run_passes = 0 SELECT 1;
SELECT '--';
@ -13,7 +13,7 @@ CREATE TABLE test_table
INSERT INTO test_table VALUES (0, 'Value');
EXPLAIN QUERY TREE SELECT id, value FROM test_table;
EXPLAIN QUERY TREE run_passes = 0 SELECT id, value FROM test_table;
SELECT '--';
@ -21,7 +21,7 @@ EXPLAIN QUERY TREE run_passes = 1 SELECT id, value FROM test_table;
SELECT '--';
EXPLAIN QUERY TREE SELECT arrayMap(x -> x + id, [1, 2, 3]) FROM test_table;
EXPLAIN QUERY TREE run_passes = 0 SELECT arrayMap(x -> x + id, [1, 2, 3]) FROM test_table;
SELECT '--';
@ -29,7 +29,7 @@ EXPLAIN QUERY TREE run_passes = 1 SELECT arrayMap(x -> x + 1, [1, 2, 3]) FROM te
SELECT '--';
EXPLAIN QUERY TREE WITH x -> x + 1 AS lambda SELECT lambda(id) FROM test_table;
EXPLAIN QUERY TREE run_passes = 0 WITH x -> x + 1 AS lambda SELECT lambda(id) FROM test_table;
SELECT '--';