Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

columns with not full loaded stats may display wrong column ID in EXPLAIN #52207

Closed
time-and-fate opened this issue Mar 28, 2024 · 0 comments · Fixed by #52208
Closed

columns with not full loaded stats may display wrong column ID in EXPLAIN #52207

time-and-fate opened this issue Mar 28, 2024 · 0 comments · Fixed by #52208
Assignees
Labels
affects-7.1 This bug affects the 7.1.x(LTS) versions. affects-7.5 This bug affects the 7.5.x(LTS) versions. severity/moderate sig/planner SIG: Planner type/bug The issue is confirmed as a bug.

Comments

@time-and-fate
Copy link
Member

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

create table t(a int, b int, c int, primary key(a), key idx(b));
insert into t values (1,1,1),(2,2,2),(3,3,3);
create table t2(a int, primary key(a));
insert into t2 values (1),(2),(3);
create table tp(a int, b int, c int, index ic(c)) partition by range(a) (partition p0 values less than (10),partition p1 values less than (20),partition p2 values less than maxvalue);
insert into tp values (1,1,1),(2,2,2),(13,13,13),(14,14,14),(25,25,25),(36,36,36);
analyze table t;
analyze table t2;
analyze table tp;
explain select * from tp;
explain select * from t1;
explain select * from t2;
set @@tidb_stats_load_sync_wait = 0;
explain format = brief select * from t join tp partition (p0) join t2 where t.a < 10 and t.b = tp.c and t2.a > 10 and t2.a = tp.c;

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

Correctly display the stats loading related information.

3. What did you see instead (Required)

Note the ID 8:allEvicted and ID 6:allEvicted in the plan. The column's ID with incomplete stats is wrong, so it fails to get the column name from the metadata and prints the column ID directly.

+-----------------------------------+---------+-----------+-----------------------+------------------------------------------------------------------------------------------------------------+
| id                                | estRows | task      | access object         | operator info                                                                                              |
+-----------------------------------+---------+-----------+-----------------------+------------------------------------------------------------------------------------------------------------+
| HashJoin                          | 0.33    | root      |                       | inner join, equal:[eq(test.tp.c, test.t2.a)]                                                               |
| ├─IndexJoin(Build)                | 0.33    | root      |                       | inner join, inner:IndexLookUp, outer key:test.t.b, inner key:test.tp.c, equal cond:eq(test.t.b, test.tp.c) |
| │ ├─TableReader(Build)            | 0.33    | root      |                       | data:Selection                                                                                             |
| │ │ └─Selection                   | 0.33    | cop[tikv] |                       | gt(test.t.b, 10), not(isnull(test.t.b))                                                                    |
| │ │   └─TableRangeScan            | 1.00    | cop[tikv] | table:t               | range:[-inf,10), keep order:false, stats:partial[idx:allEvicted, a:allEvicted, b:allEvicted]               |
| │ └─IndexLookUp(Probe)            | 0.33    | root      | partition:p0          |                                                                                                            |
| │   ├─Selection(Build)            | 0.33    | cop[tikv] |                       | gt(test.tp.c, 10), not(isnull(test.tp.c))                                                                  |
| │   │ └─IndexRangeScan            | 0.50    | cop[tikv] | table:tp, index:ic(c) | range: decided by [eq(test.tp.c, test.t.b)], keep order:false, stats:partial[ID 6:allEvicted]              |
| │   └─TableRowIDScan(Probe)       | 0.33    | cop[tikv] | table:tp              | keep order:false, stats:partial[ID 6:allEvicted]                                                           |
| └─TableReader(Probe)              | 1.00    | root      |                       | data:TableRangeScan                                                                                        |
|   └─TableRangeScan                | 1.00    | cop[tikv] | table:t2              | range:(10,+inf], keep order:false, stats:partial[a:allEvicted, ID 8:allEvicted]                            |
+-----------------------------------+---------+-----------+-----------------------+------------------------------------------------------------------------------------------------------------+

4. What is your TiDB version? (Required)

Affects from 7.1 to the current master (pre-v8.1)

@time-and-fate time-and-fate added type/bug The issue is confirmed as a bug. severity/moderate labels Mar 28, 2024
@time-and-fate time-and-fate self-assigned this Mar 28, 2024
@time-and-fate time-and-fate added affects-7.1 This bug affects the 7.1.x(LTS) versions. affects-7.5 This bug affects the 7.5.x(LTS) versions. labels Mar 28, 2024
ti-chi-bot bot pushed a commit that referenced this issue Apr 2, 2024
@time-and-fate time-and-fate added the sig/planner SIG: Planner label Apr 3, 2024
ti-chi-bot bot pushed a commit that referenced this issue Apr 8, 2024
ti-chi-bot bot pushed a commit that referenced this issue Apr 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-7.1 This bug affects the 7.1.x(LTS) versions. affects-7.5 This bug affects the 7.5.x(LTS) versions. severity/moderate sig/planner SIG: Planner type/bug The issue is confirmed as a bug.
Projects
None yet
1 participant