pingcap / tidb

TiDB - the open-source, cloud-native, distributed SQL database designed for modern applications.
https://pingcap.com
Apache License 2.0
37.22k stars 5.84k forks source link

'access object' is not included in I_S.STATEMENTS_SUMMARY tables #38279

Open mjonss opened 2 years ago

mjonss commented 2 years ago

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

create table test.t (a int) partition by hash (a) partitions 2;
insert into test.t values (1);
select * from test.t where a = 1;
explain analyze select * from test.t where a = 1;
select plan from information_schema.statements_summary where query_sample_text like 'select * from test.t where a = 1';

2. What did you expect to see? (Required)

The plan from INFORMATION_SCHEMA.STATEMENTS_SUMMARY would include the 'access object' column, to gain insights about partition pruning.

3. What did you see instead (Required)

tidb> create table test.t (a int) partition by hash (a) partitions 2;
Query OK, 0 rows affected (0,10 sec)

tidb> insert into test.t values (1);
Query OK, 1 row affected (0,01 sec)

tidb> select * from test.t where a = 1;
+------+
| a    |
+------+
|    1 |
+------+
1 row in set, 1 warning (0,00 sec)

tidb> explain analyze select * from test.t where a = 1;
+-------------------------+---------+---------+-----------+-----------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------+-----------+------+
| id                      | estRows | actRows | task      | access object         | execution info                                                                                                                                                                                            | operator info                  | memory    | disk |
+-------------------------+---------+---------+-----------+-----------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------+-----------+------+
| TableReader_9           | 0.00    | 1       | root      |                       | time:408.7µs, loops:2, cop_task: {num: 1, max: 367.1µs, proc_keys: 1, rpc_num: 1, rpc_time: 348.5µs, copr_cache_hit_ratio: 0.00, distsql_concurrency: 15}                                                 | data:Selection_8               | 235 Bytes | N/A  |
| └─Selection_8           | 0.00    | 1       | cop[tikv] |                       | tikv_task:{time:4ms, loops:1}, scan_detail: {total_process_keys: 1, total_process_keys_size: 37, total_keys: 2, get_snapshot_time: 11.2µs, rocksdb: {key_skipped_count: 1, block: {cache_hit_count: 2}}}  | eq(test.t.a, 1)                | N/A       | N/A  |
|   └─TableFullScan_7     | 1.00    | 1       | cop[tikv] | table:t, partition:p1 | tikv_task:{time:0s, loops:1}                                                                                                                                                                              | keep order:false, stats:pseudo | N/A       | N/A  |
+-------------------------+---------+---------+-----------+-----------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------+-----------+------+
3 rows in set, 1 warning (0,00 sec)

tidb> select plan from information_schema.statements_summary where query_sample_text like 'select * from test.t where a = 1';
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| plan                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|   id                  task        estRows operator info                                           actRows execution info                                                                                                                                                                                              memory      disk
    TableReader_9       root        0.00    data:Selection_8                                        1       time:1.48ms, loops:2, cop_task: {num: 1, max: 1.3ms, proc_keys: 1, rpc_num: 1, rpc_time: 1.23ms, copr_cache_hit_ratio: 0.00, distsql_concurrency: 15}                                                       234 Bytes   N/A
    └─Selection_8       cop[tikv]   0.00    eq(test.t.a, 1)                                         1       tikv_task:{time:0s, loops:1}, scan_detail: {total_process_keys: 1, total_process_keys_size: 37, total_keys: 2, get_snapshot_time: 33.3µs, rocksdb: {key_skipped_count: 1, block: {cache_hit_count: 2}}} N/A         N/A
      └─TableFullScan_7 cop[tikv]   1       table:t, partition:p1, keep order:false, stats:pseudo   1       tikv_task:{time:0s, loops:1}                                                                                                                                                                                N/A         N/A |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0,00 sec)

4. What is your TiDB version? (Required)

tidb_version(): Release Version: v6.3.0-alpha
Edition: Community
Git Commit Hash: 5ac83ce6d1de1b56b229a4c3846cfd1b1da1b922
Git Branch: heads/refs/tags/v6.3.0-alpha
UTC Build Time: 2022-09-28 14:32:59
GoVersion: go1.19.1
Race Enabled: false
TiKV Min Version: 6.2.0-alpha
Check Table Before Drop: false
Store: tikv
mjonss commented 2 years ago

Related to https://github.com/pingcap/tidb/issues/28731