-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
planner: choose TableScan when use an empty index hint #12037
Changes from 2 commits
05d95ff
aa2d13a
025f731
7245bb8
791a744
021a64b
00f8952
bc06b14
c64959b
0fc9a6c
466d0d5
034bd0e
8cfdd0c
cca636e
3b9db23
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -558,6 +558,19 @@ func (b *PlanBuilder) getPossibleAccessPaths(indexHints []*ast.IndexHint, tblInf | |
} | ||
|
||
hasScanHint = true | ||
if hint.IndexNames == nil { | ||
// If indexNames is nil, choose TablePath. | ||
// 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. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This ignore case doesn't make sense? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure. I'll remove this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is another issue. I tried
But TiDB allows such syntax. |
||
} else { | ||
hasUseOrForce = true | ||
path.forced = true | ||
available = append(available, path) | ||
} | ||
} | ||
} | ||
for _, idxName := range hint.IndexNames { | ||
path := getPathByIndexName(publicPaths, idxName, tblInfo) | ||
if path == nil { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you also consider the comment style hint like
index(t)
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed