Skip to content

Commit

Permalink
infoschema: add cluster_tidb_statements_stats table
Browse files Browse the repository at this point in the history
  • Loading branch information
henrybw committed Dec 3, 2024
1 parent 26734f7 commit 8900c16
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 deletions.
3 changes: 2 additions & 1 deletion pkg/executor/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -2328,7 +2328,8 @@ func (b *executorBuilder) buildMemTable(v *plannercore.PhysicalMemTable) exec.Ex
strings.ToLower(infoschema.TableTiDBStatementsStats),
strings.ToLower(infoschema.ClusterTableStatementsSummary),
strings.ToLower(infoschema.ClusterTableStatementsSummaryHistory),
strings.ToLower(infoschema.ClusterTableStatementsSummaryEvicted):
strings.ToLower(infoschema.ClusterTableStatementsSummaryEvicted),
strings.ToLower(infoschema.ClusterTableTiDBStatementsStats):
var extractor *plannercore.StatementsSummaryExtractor
if v.Extractor != nil {
extractor = v.Extractor.(*plannercore.StatementsSummaryExtractor)
Expand Down
11 changes: 9 additions & 2 deletions pkg/executor/stmtsummary.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,15 +346,22 @@ func isClusterTable(originalTableName string) bool {
switch originalTableName {
case infoschema.ClusterTableStatementsSummary,
infoschema.ClusterTableStatementsSummaryHistory,
infoschema.ClusterTableStatementsSummaryEvicted:
infoschema.ClusterTableStatementsSummaryEvicted,
infoschema.ClusterTableTiDBStatementsStats:
return true
}

return false
}

func isCumulativeTable(originalTableName string) bool {
return originalTableName == infoschema.TableTiDBStatementsStats
switch originalTableName {
case infoschema.TableTiDBStatementsStats,
infoschema.ClusterTableTiDBStatementsStats:
return true
}

return false
}

func isCurrentTable(originalTableName string) bool {
Expand Down
3 changes: 3 additions & 0 deletions pkg/infoschema/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ const (
ClusterTableStatementsSummaryHistory = "CLUSTER_STATEMENTS_SUMMARY_HISTORY"
// ClusterTableStatementsSummaryEvicted is the string constant of cluster statement summary evict table.
ClusterTableStatementsSummaryEvicted = "CLUSTER_STATEMENTS_SUMMARY_EVICTED"
// ClusterTableTiDBStatementsStats is the string constant of the cluster statement stats table.
ClusterTableTiDBStatementsStats = "CLUSTER_TIDB_STATEMENTS_STATS"
// ClusterTableTiDBTrx is the string constant of cluster transaction running table.
ClusterTableTiDBTrx = "CLUSTER_TIDB_TRX"
// ClusterTableDeadlocks is the string constant of cluster dead lock table.
Expand All @@ -65,6 +67,7 @@ var memTableToAllTiDBClusterTables = map[string]string{
TableStatementsSummary: ClusterTableStatementsSummary,
TableStatementsSummaryHistory: ClusterTableStatementsSummaryHistory,
TableStatementsSummaryEvicted: ClusterTableStatementsSummaryEvicted,
TableTiDBStatementsStats: ClusterTableTiDBStatementsStats,
TableTiDBTrx: ClusterTableTiDBTrx,
TableDeadlocks: ClusterTableDeadlocks,
TableTrxSummary: ClusterTableTrxSummary,
Expand Down
1 change: 1 addition & 0 deletions pkg/infoschema/tables.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ var tableIDMap = map[string]int64{
TableTiDBPlanCache: autoid.InformationSchemaDBID + 96,
ClusterTableTiDBPlanCache: autoid.InformationSchemaDBID + 97,
TableTiDBStatementsStats: autoid.InformationSchemaDBID + 98,
ClusterTableTiDBStatementsStats: autoid.InformationSchemaDBID + 99,
}

// columnInfo represents the basic column information of all kinds of INFORMATION_SCHEMA tables
Expand Down
1 change: 1 addition & 0 deletions pkg/planner/core/operator/logicalop/logical_mem_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ func (p *LogicalMemTable) PruneColumns(parentUsedCols []*expression.Column, opt
infoschema.TableSlowQuery,
infoschema.ClusterTableStatementsSummary,
infoschema.ClusterTableStatementsSummaryHistory,
infoschema.ClusterTableTiDBStatementsStats,
infoschema.ClusterTableSlowLog,
infoschema.TableTiDBTrx,
infoschema.ClusterTableTiDBTrx,
Expand Down

0 comments on commit 8900c16

Please sign in to comment.