Skip to content

Commit

Permalink
Merge pull request #93143 from adityamaru/show-backup-speedup
Browse files Browse the repository at this point in the history
release-22.1: backupccl: elide expensive ShowCreate call in SHOW BACKUP
  • Loading branch information
adityamaru committed Dec 6, 2022
2 parents 97a6623 + 3c20609 commit 3b76f78
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions pkg/ccl/backupccl/show.go
Expand Up @@ -578,18 +578,23 @@ func backupShowerDefault(
dataSizeDatum = tree.NewDInt(tree.DInt(tableSize.DataSize))
rowCountDatum = tree.NewDInt(tree.DInt(tableSize.Rows))

displayOptions := sql.ShowCreateDisplayOptions{
FKDisplayMode: sql.OmitMissingFKClausesFromCreate,
IgnoreComments: true,
// Only resolve the table schemas if running `SHOW BACKUP SCHEMAS`.
// In all other cases we discard these results and so it is wasteful
// to construct the SQL representation of the table's schema.
if showSchemas {
displayOptions := sql.ShowCreateDisplayOptions{
FKDisplayMode: sql.OmitMissingFKClausesFromCreate,
IgnoreComments: true,
}
createStmt, err := p.ShowCreate(ctx, dbName, manifest.Descriptors,
tabledesc.NewBuilder(desc.TableDesc()).BuildImmutableTable(), displayOptions)
if err != nil {
// We expect that we might get an error here due to X-DB
// references, which were possible on 20.2 betas and rcs.
log.Errorf(ctx, "error while generating create statement: %+v", err)
}
createStmtDatum = nullIfEmpty(createStmt)
}
createStmt, err := p.ShowCreate(ctx, dbName, manifest.Descriptors,
tabledesc.NewBuilder(desc.TableDesc()).BuildImmutableTable(), displayOptions)
if err != nil {
// We expect that we might get an error here due to X-DB
// references, which were possible on 20.2 betas and rcs.
log.Errorf(ctx, "error while generating create statement: %+v", err)
}
createStmtDatum = nullIfEmpty(createStmt)
default:
descriptorType = "unknown"
}
Expand Down

0 comments on commit 3b76f78

Please sign in to comment.