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

Skyline pruning prunes maybe-good prefix index #27313

Closed
Tracked by #26020
xuyifangreeneyes opened this issue Aug 17, 2021 · 3 comments · Fixed by #27527
Closed
Tracked by #26020

Skyline pruning prunes maybe-good prefix index #27313

xuyifangreeneyes opened this issue Aug 17, 2021 · 3 comments · Fixed by #27527
Assignees
Labels
severity/moderate sig/planner SIG: Planner type/bug The issue is confirmed as a bug.

Comments

@xuyifangreeneyes
Copy link
Contributor

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

use test;
drop table if exists t;
create table t(a varchar(100), b int, c int, index idx1(a(2), b), index idx2(a));
explain format = 'verbose' select * from t where a = 'abcdefghijk' and b > 4;

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

idx2 remains after skyline pruning.

3. What did you see instead (Required)

idx2 is pruned since skyline pruning thinks it is worse than idx1, which is not true considering the index column prefix length.

mysql> explain format = 'verbose' select * from t where a = 'abcdefghijk' and b > 4;
+-------------------------------+---------+---------+-----------+---------------------------+----------------------------------------------------------+
| id                            | estRows | estCost | task      | access object             | operator info                                            |
+-------------------------------+---------+---------+-----------+---------------------------+----------------------------------------------------------+
| IndexLookUp_11                | 33.33   | 678.84  | root      |                           |                                                          |
| ├─IndexRangeScan_8(Build)     | 33.33   | 2370.00 | cop[tikv] | table:t, index:idx1(a, b) | range:("ab" 4,"ab" +inf], keep order:false, stats:pseudo |
| └─Selection_10(Probe)         | 33.33   | 0.00    | cop[tikv] |                           | eq(test.t.a, "abcdefghijk")                              |
|   └─TableRowIDScan_9          | 33.33   | 2370.00 | cop[tikv] | table:t                   | keep order:false, stats:pseudo                           |
+-------------------------------+---------+---------+-----------+---------------------------+----------------------------------------------------------+
4 rows in set, 1 warning (0.00 sec)

mysql> show warnings;
+-------+------+---------------------------------------------------------------------------------------+
| Level | Code | Message                                                                               |
+-------+------+---------------------------------------------------------------------------------------+
| Note  | 1105 | [t,idx1] remain after pruning paths for t given Prop{SortItems: [], TaskTp: rootTask} |
+-------+------+---------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

4. What is your TiDB version? (Required)

mysql> SELECT tidb_version();
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version()                                                                                                                                                                                                                                                                                                            |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v5.2.0-alpha-653-g4a3c290c0
Edition: Community
Git Commit Hash: 4a3c290c0b6f80d9d3eea430a59bfc2f9cb9c78f
Git Branch: master
UTC Build Time: 2021-08-17 11:10:12
GoVersion: go1.16.4
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
@xuyifangreeneyes xuyifangreeneyes added the type/bug The issue is confirmed as a bug. label Aug 17, 2021
@xuyifangreeneyes
Copy link
Contributor Author

/sig planner

@xuyifangreeneyes
Copy link
Contributor Author

/assign

@github-actions
Copy link

Please check whether the issue should be labeled with 'affects-x.y' or 'fixes-x.y.z', and then remove 'needs-more-info' label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity/moderate sig/planner SIG: Planner type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants