-
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: use TableInfo.DBID to locate schema #57785
Conversation
Hi @tangenta. Thanks for your PR. PRs from untrusted users cannot be marked as trusted with I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #57785 +/- ##
================================================
+ Coverage 72.8945% 73.4878% +0.5933%
================================================
Files 1677 1677
Lines 464463 465983 +1520
================================================
+ Hits 338568 342441 +3873
+ Misses 104989 102665 -2324
+ Partials 20906 20877 -29
Flags with carried forward coverage won't be shown. Click here to find out more.
|
tableSlice []*model.TableInfo, | ||
) ([]pmodel.CIStr, []*model.TableInfo, error) { | ||
schemaSlice := make([]pmodel.CIStr, 0, len(tableSlice)) | ||
for i, tbl := range tableSlice { | ||
dbInfo, ok := is.SchemaByID(tbl.DBID) |
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.
Seem like DBID
field is not persisted, can we use this field to do search?
Sorry, I found it's set in GetTable
func (e *InfoSchemaBaseExtractor) listExtractedSchemas( | ||
is infoschema.InfoSchema, | ||
) (schemas []pmodel.CIStr, unspecified bool) { |
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.
Although we can use schemas == nil
to indicate no predicate is specified, developers may get confused to distinguish from len(schemas) == 0
.
@@ -150,7 +159,8 @@ func (e *InfoSchemaBaseExtractor) ListSchemasAndTables( | |||
findTablesByID(is, tableIDs, tableNames, tableMap) | |||
tableSlice := maps.Values(tableMap) | |||
tableSlice = filterSchemaObjectByRegexp(e, ec.table, tableSlice, extractStrTableInfo) | |||
return findSchemasForTables(ctx, is, schemas, tableSlice) | |||
schemas, unspecified := e.listExtractedSchemas(is) |
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.
By the way, it's a bit weird to check predicates by ec.tableID != ""
(Not related to this PR although)
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.
Do you mean we should decide this at the compile time? Do you have any suggestions?
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.
Nevermind, because I have no suggestion yet :(
@joechenrh: adding LGTM is restricted to approvers and reviewers in OWNERS files. In response to this: Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
schemaSlice := make([]pmodel.CIStr, 0, len(tableSlice)) | ||
for i, tbl := range tableSlice { | ||
dbInfo, ok := is.SchemaByID(tbl.DBID) | ||
if !ok { | ||
continue |
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.
Something is wrong? how about add some log in this situation?
[LGTM Timeline notifier]Timeline:
|
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.
Looks good to me. Thanks!
if len(tableNames) > 0 { | ||
tableNames = filterSchemaObjectByRegexp(e, ec.table, tableNames, extractStrCIStr) | ||
schemas := e.ListSchemas(is) | ||
return findTableAndSchemaByName(ctx, is, schemas, tableNames) | ||
} | ||
schemas := e.ListSchemas(is) | ||
return listTablesForEachSchema(ctx, e, is, schemas) |
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.
if len(tableNames) > 0 { | |
tableNames = filterSchemaObjectByRegexp(e, ec.table, tableNames, extractStrCIStr) | |
schemas := e.ListSchemas(is) | |
return findTableAndSchemaByName(ctx, is, schemas, tableNames) | |
} | |
schemas := e.ListSchemas(is) | |
return listTablesForEachSchema(ctx, e, is, schemas) | |
schemas := e.ListSchemas(is) | |
if len(tableNames) > 0 { | |
tableNames = filterSchemaObjectByRegexp(e, ec.table, tableNames, extractStrCIStr) | |
return findTableAndSchemaByName(ctx, is, schemas, tableNames) | |
} | |
return listTablesForEachSchema(ctx, e, is, schemas) |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: joechenrh, lance6716, Rustin170506, tiancaiamao The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
In response to a cherrypick label: new pull request created to branch |
What problem does this PR solve?
Issue Number: close #57783, close #57779
Problem Summary:
When
tableInfo
is located, it is unnecessary to read all databases to match.What changed and how does it work?
This PR changes to use
TableInfo.DBID
to locate the schema.Check List
Tests
Use the same environment mentioned in It takes too long time for add index in million tables #57783:
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.