diff --git a/go/vt/schemamanager/tablet_executor.go b/go/vt/schemamanager/tablet_executor.go index 995b3f8cafe..4857f592fb1 100644 --- a/go/vt/schemamanager/tablet_executor.go +++ b/go/vt/schemamanager/tablet_executor.go @@ -217,6 +217,17 @@ func (exec *TabletExecutor) isOnlineSchemaDDL(stmt sqlparser.Statement) (isOnlin // 1. Alter more than 100,000 rows. // 2. Change a table with more than 2,000,000 rows (Drops are fine). func (exec *TabletExecutor) detectBigSchemaChanges(ctx context.Context, parsedDDLs []sqlparser.DDLStatement) (bool, error) { + // We want to avoid any overhead if possible. If all DDLs are online schema changes, then we want to + // skip GetSchema altogether. + foundAnyNonOnlineDDL := false + for _, ddl := range parsedDDLs { + if !exec.isOnlineSchemaDDL(ddl) { + foundAnyNonOnlineDDL = true + } + } + if !foundAnyNonOnlineDDL { + return false, nil + } // exec.tablets is guaranteed to have at least one element; // Otherwise, Open should fail and executor should fail. primaryTabletInfo := exec.tablets[0]