Skip to content

Commit

Permalink
Merge pull request #7590 from planetscale/vtexplain-show-status
Browse files Browse the repository at this point in the history
Add Show Status query to vtexplain and make asthelpergen/sizegen quiet
  • Loading branch information
systay authored Mar 3, 2021
2 parents 25c1088 + 78cefb0 commit 436188f
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 3 deletions.
2 changes: 2 additions & 0 deletions go/mysql/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import (
const (
// BaseShowPrimary is the base query for fetching primary key info.
BaseShowPrimary = "SELECT table_name, column_name FROM information_schema.key_column_usage WHERE table_schema=database() AND constraint_name='PRIMARY' ORDER BY table_name, ordinal_position"
// ShowRowsRead is the query used to find the number of rows read.
ShowRowsRead = "show status like 'Innodb_rows_read'"
)

// BaseShowTablesFields contains the fields returned by a BaseShowTables or a BaseShowTablesForTable command.
Expand Down
1 change: 0 additions & 1 deletion go/tools/asthelpergen/asthelpergen.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ func VerifyFilesOnDisk(result map[string]*jen.File) (errors []error) {
func GenerateASTHelpers(packagePatterns []string, rootIface, exceptCloneType string) (map[string]*jen.File, error) {
loaded, err := packages.Load(&packages.Config{
Mode: packages.NeedName | packages.NeedTypes | packages.NeedTypesSizes | packages.NeedTypesInfo | packages.NeedDeps | packages.NeedImports | packages.NeedModule,
Logf: log.Printf,
}, packagePatterns...)

if err != nil {
Expand Down
1 change: 0 additions & 1 deletion go/tools/sizegen/sizegen.go
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,6 @@ func VerifyFilesOnDisk(result map[string]*jen.File) (errors []error) {
func GenerateSizeHelpers(packagePatterns []string, typePatterns []string) (map[string]*jen.File, error) {
loaded, err := packages.Load(&packages.Config{
Mode: packages.NeedName | packages.NeedTypes | packages.NeedTypesSizes | packages.NeedTypesInfo | packages.NeedDeps | packages.NeedImports | packages.NeedModule,
Logf: log.Printf,
}, packagePatterns...)

if err != nil {
Expand Down
7 changes: 7 additions & 0 deletions go/vt/vtexplain/vtexplain_vttablet.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,13 @@ func initTabletEnvironment(ddls []sqlparser.DDLStatement, opts *Options) error {
}},
Rows: [][]sqltypes.Value{},
},
mysql.ShowRowsRead: sqltypes.MakeTestResult(
sqltypes.MakeTestFields(
"Variable_name|value",
"varchar|uint64",
),
"Innodb_rows|0",
),
}

showTableRows := make([][]sqltypes.Value, 0, 4)
Expand Down
2 changes: 1 addition & 1 deletion go/vt/vttablet/tabletserver/schema/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ func (se *Engine) reload(ctx context.Context) error {
}

func (se *Engine) updateInnoDBRowsRead(ctx context.Context, conn *connpool.DBConn) error {
readRowsData, err := conn.Exec(ctx, "show status like 'Innodb_rows_read'", 10, false)
readRowsData, err := conn.Exec(ctx, mysql.ShowRowsRead, 10, false)
if err != nil {
return err
}
Expand Down

0 comments on commit 436188f

Please sign in to comment.