Tree based explain format
- Dominant language
- Go
- Stars
- 40.5k
- Forks
- 6.2k
- PR merge metrics
- PR metrics pending
Description
## Feature Request
This has long lines that cause very long lines, leading to either line wrapping and/or scrolling (with `pager less -SL`). And in vertical format (`\G` in MySQL Client) the tree that is in the left column no longer looks like a tree.
Issues:
- Long lines
- Tree (in `id` column) not looking correct due to line wrapping or verical output
Current output:
```
mysql-8.0.11-TiDB-v8.5.5 [test]> explain analyze SELECT u.User, u.Host, d.DB FROM mysql.user u JOIN mysql.db d on d.user=u.user and d.host=u.host;
+-------------------------------+----------+---------+-----------+----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------+-----------+---------+
| id | estRows | actRows | task | access object | execution info | operator info | memory | disk |
+-------------------------------+----------+---------+-----------+----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------+-----------+---------+
| Projection_7 | 12500.00 | 0 | root | | time:1.63ms, loops:1, RU:1.02, Concurrency:5 | mysql.user.user, mysql.user.host, mysql.db.db | 18.6 KB | N/A |
| └─HashJoin_26 | 12500.00 | 0 | root | | time:1.5ms, loops:1, build_hash_table:{total:1.32ms, fetch:1.3ms, build:14.7µs} | inner join, equal:[eq(mysql.user.user, mysql.db.user) eq(mysql.user.host, mysql.db.host)] | 108.6 KB | 0 Bytes |
| ├─IndexReader_30(Build) | 10000.00 | 1 | root | | time:1.18ms, loops:2, cop_task: {num: 1, max: 1.09ms, proc_keys: 1, tot_proc: 125.2µs, tot_wait: 163.7µs, copr_cache_hit_ratio: 0.00, build_task_duration: 17µs, max_distsql_concurrency: 1}, rpc_info:{Cop:{num_rpc:1, total_time:1.05ms}} | index:IndexFullScan_29 | 303 Bytes | N/A |
| │ └─IndexFullScan_29 | 10000.00 | 1 | cop[tikv] | table:u, index:PRIMARY(Host, User) | tikv_task:{time:1ms, loops:1}, scan_detail: {total_process_keys: 1, total_process_keys_size: 53, total_keys: 2, get_snapshot_time: 45.3µs, rocksdb: {delete_skipped_count: 1, key_skipped_count: 2, block: {}}}, time_detail: {total_process_time: 125.2µs, total_wait_time: 163.7µs, total_kv_read_wall_time: 1ms, tikv_wall_time: 508.5µs} | keep order:false, stats:pseudo | N/A | N/A |
| └─IndexReader_34(Probe) | 10000.00 | 0 | root | | time:993µs, loops:1, cop_task: {num: 1, max: 1.14ms, proc_keys: 0, tot_proc: 89.8µs, tot_wait: 117.9µs, copr_cache_hit_ratio: 0.00, build_task_duration: 4.76µs, max_distsql_concurrency: 1}, rpc_info:{Cop:{num_rpc:1, total_time:1.09ms}} | index:IndexFullScan_33 | 226 Bytes | N/A |
| └─IndexFullScan_33 | 10000.00 | 0 | cop[tikv] | table:d, index:PRIMARY(Host, DB, User) | tikv_task:{time:0s, loops:1}, scan_detail: {total_keys: 1, get_snapshot_time: 53.2µs, rocksdb: {block: {}}}, time_detail: {total_process_time: 89.8µs, total_wait_time: 117.9µs, tikv_wall_time: 447µs} | keep order:false, stats:pseudo | N/A | N/A |
+-------------------------------+----------+---------+-----------+----------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------+-----------+---------+
6 rows in set (0.005 sec)
```
Mock tree based format
```
mysql-8.0.11-TiDB-v8.5.5 [test]> explain analyze FORMAT=TREE SELECT u.User, u.Host, d.DB FROM mysql.user u JOIN mysql.db d on d.user=u.user and d.host=u.host;
-> Projection_7 (estRows: 12500.00, actRows: 0) task:root
time:1.63ms, loops:1, RU:1.02, Concurrency:5
operator info: mysql.user.user, mysql.user.host, mysql.db.db
memory: 18.6 KB, disk: N/A
-> HashJoin_26 (estRows: 12500.00, actRows: 0) task:root
time:1.5ms, loops:1, build_hash_table:{total:1.32ms, fetch:1.3ms, build:14.7µs}
operator info: inner join, equal:[eq(mysql.user.user, mysql.db.user) eq(mysql.user.host, mysql.db.host)]
memory: 108.6 KB, disk: 0 Bytes
-> IndexReader_30(Build) (estRows: 10000.00, actRows: 1) task:root
time:1.18ms, loops:2,
cop_task: {
num: 1, max: 1.09ms, proc_keys: 1, tot_proc: 125.2µs, tot_wait: 163.7µs, copr_cache_hit_ratio: 0.00, build_task_duration: 17µs, max_distsql_concurrency: 1
},
rpc_info:{Cop:{num_rpc:1, total_time:1.05ms}}
operator info: index:IndexFullScan_29
memory: 303 Bytes, disk: N/A
-> IndexFullScan_29 (estRows: 10000.00, actRows:1) task:cop[tikv]
objects: table:u, index:PRIMARY(Host, User)
tikv_task:{time:1ms, loops:1},
scan_detail: {
total_process_keys: 1, total_process_keys_size: 53, total_keys: 2, get_snapshot_time: 45.3µs, rocksdb: {delete_skipped_count: 1, key_skipped_count: 2, block: {}}
},
time_detail: {total_process_time: 125.2µs, total_wait_time: 163.7µs, total_kv_read_wall_time: 1ms, tikv_wall_time: 508.5µs}
operator info: keep order:false, stats:pseudo
memory: N/A, disk: N/A
-> IndexReader_34(Probe) (estRows: 10000.00, actRows: 0) task:root
time:993µs, loops:1,
cop_task: {
num: 1, max: 1.14ms, proc_keys: 0, tot_proc: 89.8µs, tot_wait: 117.9µs, copr_cache_hit_ratio: 0.00, build_task_duration: 4.76µs, max_distsql_concurrency: 1}, rpc_info:{Cop:{num_rpc:1, total_time:1.09ms}
}
operator info: index:IndexFullScan_33
memory: 226 Bytes, disk: N/A
-> IndexFullScan_33 (estRows: 10000.00, actRows: 0) task:cop[tikv]
objects: table:d, index:PRIMARY(Host, DB, User)
tikv_task:{time:0s, loops:1}, scan_detail: {total_keys: 1, get_snapshot_time: 53.2µs, rocksdb: {block: {}}}, time_detail: {total_process_time: 89.8µs, total_wait_time: 117.9µs, tikv_wall_time: 447µs}
operator info: keep order:false, stats:pseudo
memory: N/A, disk: N/A
```
Contributor guide
Assessment
This issue has not been assessed yet.