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

expressional index can be used when have duplicate expresion #25729

Closed
wjhuang2016 opened this issue Jun 24, 2021 · 2 comments · Fixed by #25826
Closed

expressional index can be used when have duplicate expresion #25729

wjhuang2016 opened this issue Jun 24, 2021 · 2 comments · Fixed by #25826
Assignees
Labels
severity/moderate sig/planner SIG: Planner type/bug The issue is confirmed as a bug.

Comments

@wjhuang2016
Copy link
Member

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

create table tt(a int, b int, key k((a+1)), key k1((a+1), b), key k2((a+1), b), key k3((a+1)));
desc select * from tt where a+1 = 5 and b=3;
desc select * from tt where a+1 = 5 and b=3;

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

stable plan

3. What did you see instead (Required)

mysql> desc select * from tt where a+1 = 5 and b=3;
+---------------------------------+---------+-----------+-----------------------------+---------------------------------------------+
| id                              | estRows | task      | access object               | operator info                               |
+---------------------------------+---------+-----------+-----------------------------+---------------------------------------------+
| Projection_4                    | 0.01    | root      |                             | test.tt.a, test.tt.b                        |
| └─IndexLookUp_12                | 0.01    | root      |                             |                                             |
|   ├─IndexRangeScan_9(Build)     | 10.00   | cop[tikv] | table:tt, index:k3(`a` + 1) | range:[5,5], keep order:false, stats:pseudo |
|   └─Selection_11(Probe)         | 0.01    | cop[tikv] |                             | eq(test.tt.b, 3)                            |
|     └─TableRowIDScan_10         | 10.00   | cop[tikv] | table:tt                    | keep order:false, stats:pseudo              |
+---------------------------------+---------+-----------+-----------------------------+---------------------------------------------+
5 rows in set (0.00 sec)

mysql> desc select * from tt where a+1 = 5 and b=3;
+----------------------------------+---------+-----------+--------------------------------+-------------------------------------------------+
| id                               | estRows | task      | access object                  | operator info                                   |
+----------------------------------+---------+-----------+--------------------------------+-------------------------------------------------+
| Projection_4                     | 0.10    | root      |                                | test.tt.a, test.tt.b                            |
| └─IndexLookUp_11                 | 0.10    | root      |                                |                                                 |
|   ├─IndexRangeScan_9(Build)      | 0.10    | cop[tikv] | table:tt, index:k2(`a` + 1, b) | range:[5 3,5 3], keep order:false, stats:pseudo |
|   └─TableRowIDScan_10(Probe)     | 0.10    | cop[tikv] | table:tt                       | keep order:false, stats:pseudo                  |
+----------------------------------+---------+-----------+--------------------------------+-------------------------------------------------+
4 rows in set (0.00 sec)

4. What is your TiDB version? (Required)

master

@wjhuang2016 wjhuang2016 added the type/bug The issue is confirmed as a bug. label Jun 24, 2021
@zhuo-zhi
Copy link
Contributor

/assign

@ti-srebot
Copy link
Contributor

Please edit this comment or add a new comment to complete the following information

Not a bug

  1. Remove the 'type/bug' label
  2. Add notes to indicate why it is not a bug

Duplicate bug

  1. Add the 'type/duplicate' label
  2. Add the link to the original bug

Bug

Note: Make Sure that 'component', and 'severity' labels are added
Example for how to fill out the template: #20100

1. Root Cause Analysis (RCA) (optional)

2. Symptom (optional)

3. All Trigger Conditions (optional)

4. Workaround (optional)

5. Affected versions

6. Fixed versions

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.

4 participants