planner: choose TableScan when use an empty index hint#12037
Conversation
Codecov Report
@@ Coverage Diff @@
## master #12037 +/- ##
===========================================
Coverage 81.8853% 81.8853%
===========================================
Files 447 447
Lines 97159 97159
===========================================
Hits 79559 79559
Misses 12071 12071
Partials 5529 5529 |
| // For example: `select a from t use index()`. | ||
| if path := getTablePath(publicPaths); path != nil { | ||
| if hint.HintType == ast.HintIgnore { | ||
| ignored = append(ignored, path) |
There was a problem hiding this comment.
This ignore case doesn't make sense?
There was a problem hiding this comment.
Sure. I'll remove this.
There was a problem hiding this comment.
I think this is another issue. I tried ignore index() in MySQL, it returns a syntax Error.
mysql> explain select b from tt ignore index();
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1
But TiDB allows such syntax.
| } | ||
|
|
||
| hasScanHint = true | ||
| if hint.IndexNames == nil { |
There was a problem hiding this comment.
Could you also consider the comment style hint like index(t)?
| // For example: `select a from t use index()`. | ||
| if path := getTablePath(publicPaths); path != nil { | ||
| hasUseOrForce = true | ||
| path.forced = true |
There was a problem hiding this comment.
You need check whether is ignore or force.
Or you'll set table path as forced although no index is ignored by IGNORE INDEX()
|
/rebuild |
|
/run-all-tests |
|
/rebuild |
|
/run-all-tests |
1 similar comment
|
/run-all-tests |
|
/rebuild |
| } | ||
|
|
||
| hasScanHint = true | ||
| if hint.IndexNames == nil && hint.HintType != ast.HintIgnore { |
There was a problem hiding this comment.
How about adding a comment? From MySQL document:
It is syntactically valid to omit index_list for USE INDEX, which means “use no indexes.” Omitting index_list for FORCE INDEX or IGNORE INDEX is a syntax error.
|
/run-all-tests |
What problem does this PR solve?
fix #12033.
schema:
before this pr:
after this pr:
What is changed and how it works?
Check List
Tests