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

Cache info schema table info #13724

Merged
merged 3 commits into from
Aug 8, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions go/vt/vtgate/semantics/info_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -1671,16 +1671,25 @@ type infoSchemaWithColumns struct {
infoSchemaData map[string][]vindexes.Column
}

// We cache this information. If the registered mysql version is changed, we flush the cache
systay marked this conversation as resolved.
Show resolved Hide resolved
var cacheSchemaInfo map[string][]vindexes.Column
var cachedVersion string

// newSchemaInfo returns a SchemaInformation that has the column information for all info_schema tables
func newSchemaInfo(inner SchemaInformation) SchemaInformation {
version := servenv.MySQLServerVersion()
var infoSchema map[string][]vindexes.Column
if strings.HasPrefix(version, "5.7") {
infoSchema = getInfoSchema57()
} else {
infoSchema = getInfoSchema80()

if version != cachedVersion || cacheSchemaInfo == nil {
// we don't have a valid cached info_schema map with column information
if strings.HasPrefix(version, "5.7") {
cacheSchemaInfo = getInfoSchema57()
} else {
cacheSchemaInfo = getInfoSchema80()
}
cachedVersion = version
}
return &infoSchemaWithColumns{inner: inner, infoSchemaData: infoSchema}

return &infoSchemaWithColumns{inner: inner, infoSchemaData: cacheSchemaInfo}
}

// FindTableOrVindex implements the SchemaInformation interface
Expand Down