Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
feat: implement check pg_stat_statments enabled and sync slow query logs for PostgreSQL (#5628)
rebelicedc90497d9619
diff --git a/backend/api/v1/instance_service.go b/backend/api/v1/instance_service.goindex 9c19bf9ea7..9cfa74970e 100644--- a/backend/api/v1/instance_service.go+++ b/backend/api/v1/instance_service.go@@ -4,6 +4,7 @@ import ("context""fmt"+ "go.uber.org/zap""google.golang.org/grpc/codes""google.golang.org/grpc/status""google.golang.org/protobuf/types/known/emptypb"@@ -11,6 +12,7 @@ import ("github.com/pkg/errors""github.com/bytebase/bytebase/backend/common"+ "github.com/bytebase/bytebase/backend/common/log""github.com/bytebase/bytebase/backend/component/dbfactory""github.com/bytebase/bytebase/backend/component/state"enterpriseAPI "github.com/bytebase/bytebase/backend/enterprise/api"@@ -189,18 +191,59 @@ func (s *InstanceService) SyncSlowQueries(ctx context.Context, request *v1pb.Synreturn nil, status.Errorf(codes.NotFound, "instance %q not found", request.Instance)}- driver, err := s.dbFactory.GetAdminDatabaseDriver(ctx, instance, "" /* database name */)- if err != nil {- return nil, err- }- defer driver.Close(ctx)- if err := driver.CheckSlowQueryLogEnabled(ctx); err != nil {- return nil, status.Errorf(codes.FailedPrecondition, "slow query log is not enabled: %s", err.Error())- }+ switch instance.Engine {+ case db.MySQL:+ driver, err := s.dbFactory.GetAdminDatabaseDriver(ctx, instance, "" /* database name */)+ if err != nil {+ return nil, err+ }+ defer driver.Close(ctx)+ if err := driver.CheckSlowQueryLogEnabled(ctx); err != nil {+ return nil, status.Errorf(codes.FailedPrecondition, "slow query log is not enabled: %s", err.Error())+ }++ // Sync slow queries for instance.+ s.stateCfg.InstanceSlowQuerySyncChan <- composedInstance+ case db.Postgres:+ databases, err := s.store.ListDatabases(ctx, &store.FindDatabaseMessage{+ InstanceID: &instance.ResourceID,+ })+ if err != nil {+ return nil, status.Errorf(codes.Internal, "failed to list databases: %s", err.Error())+ }+ var firstDatabase string+ for _, database := range databases {+ if database.SyncState != api.OK {+ continue+ }+ if err := func() error {+ driver, err := s.dbFactory.GetAdminDatabaseDriver(ctx, instance, database.DatabaseName)+ if err != nil {+ return err+ }+ defer driver.Close(ctx)+ return driver.CheckSlowQueryLogEnabled(ctx)+ }(); err != nil {+ log.Warn("pg_stat_statements is not enabled",+ zap.String("instance", instance.ResourceID),+ zap.String("database", database.DatabaseName),+ zap.Int("databaseID", database.UID),+ zap.Error(err))+ }++ if firstDatabase == "" {+ firstDatabase = database.DatabaseName+ }+ }++ if firstDatabase == "" {+ return nil, status.Errorf(codes.FailedPrecondition, "no database enabled pg_stat_statements")+ }- if instance.Engine == db.MySQL {// Sync slow queries for instance.s.stateCfg.InstanceSlowQuerySyncChan <- composedInstance+ default:+ return nil, status.Errorf(codes.InvalidArgument, "unsupported engine %q", instance.Engine)}return &emptypb.Empty{}, nildiff --git a/backend/plugin/db/driver.go b/backend/plugin/db/driver.goindex 280d0173a8..4f5297101f 100644--- a/backend/plugin/db/driver.go+++ b/backend/plugin/db/driver.go@@ -474,7 +474,7 @@ type Driver interface {// Sync slow query logs// SyncSlowQuery syncs the slow query logs.- // The returned map is keyed by database name, and the value is a map keyed by query fingerprint.+ // The returned map is keyed by database name, and the value is list of slow query statistics grouped by query fingerprint.SyncSlowQuery(ctx context.Context, logDateTs time.Time) (map[string]*storepb.SlowQueryStatistics, error)// CheckSlowQueryLogEnabled checks if the slow query log is enabled.CheckSlowQueryLogEnabled(ctx context.Context) errordiff --git a/backend/plugin/db/pg/sync.go b/backend/plugin/db/pg/sync.goindex 911938e650..558136b73c 100644--- a/backend/plugin/db/pg/sync.go+++ b/backend/plugin/db/pg/sync.go@@ -10,6 +10,8 @@ import ("time""github.com/pkg/errors"+ "google.golang.org/protobuf/types/known/durationpb"+ "google.golang.org/protobuf/types/known/timestamppb""google.golang.org/protobuf/types/known/wrapperspb""github.com/bytebase/bytebase/backend/common"@@ -603,11 +605,118 @@ func getIndexMethodType(stmt string) string {}// SyncSlowQuery syncs the slow query.-func (*Driver) SyncSlowQuery(_ context.Context, _ time.Time) (map[string]*storepb.SlowQueryStatistics, error) {- return nil, errors.Errorf("not implemented")+func (driver *Driver) SyncSlowQuery(ctx context.Context, _ time.Time) (map[string]*storepb.SlowQueryStatistics, error) {+ var now time.Time+ getNow := `SELECT NOW();`+ nowRows, err := driver.db.QueryContext(ctx, getNow)+ if err != nil {+ return nil, util.FormatErrorWithQuery(err, getNow)+ }+ defer nowRows.Close()+ for nowRows.Next() {+ if err := nowRows.Scan(&now); err != nil {+ return nil, util.FormatErrorWithQuery(err, getNow)+ }+ }+ if err := nowRows.Err(); err != nil {+ return nil, util.FormatErrorWithQuery(err, getNow)+ }++ result := make(map[string]*storepb.SlowQueryStatistics)+ query := `+ SELECT+ pg_database.datname,+ query,+ calls,+ total_exec_time,+ max_exec_time,+ rows+ FROM+ pg_stat_statements+ JOIN pg_database ON pg_database.oid = pg_stat_statements.dbid;+ `++ slowQueryStatisticsRows, err := driver.db.QueryContext(ctx, query)+ if err != nil {+ return nil, util.FormatErrorWithQuery(err, query)+ }+ defer slowQueryStatisticsRows.Close()+ for slowQueryStatisticsRows.Next() {+ var database string+ var fingerprint string+ var calls int64+ var totalExecTime float64+ var maxExecTime float64+ var rows int64+ if err := slowQueryStatisticsRows.Scan(&database, &fingerprint, &calls, &totalExecTime, &maxExecTime, &rows); err != nil {+ return nil, err+ }+ if len(fingerprint) > db.SlowQueryMaxLen {+ fingerprint = fingerprint[:db.SlowQueryMaxLen]+ }+ item := storepb.SlowQueryStatisticsItem{+ SqlFingerprint: fingerprint,+ Count: calls,+ LatestLogTime: timestamppb.New(now),+ TotalQueryTime: durationpb.New(time.Duration(totalExecTime * float64(time.Millisecond))),+ MaximumQueryTime: durationpb.New(time.Duration(maxExecTime * float64(time.Millisecond))),+ TotalRowsSent: rows,+ }+ if statistics, exists := result[database]; exists {+ statistics.Items = append(statistics.Items, &item)+ } else {+ result[database] = &storepb.SlowQueryStatistics{+ Items: []*storepb.SlowQueryStatisticsItem{&item},+ }+ }+ }+ if err := slowQueryStatisticsRows.Err(); err != nil {+ return nil, err+ }++ reset := `SELECT pg_stat_statements_reset();`+ if _, err := driver.db.ExecContext(ctx, reset); err != nil {+ return nil, util.FormatErrorWithQuery(err, reset)+ }+ return result, nil}// CheckSlowQueryLogEnabled checks if slow query log is enabled.-func (*Driver) CheckSlowQueryLogEnabled(_ context.Context) error {- return errors.Errorf("not implemented")+func (driver *Driver) CheckSlowQueryLogEnabled(ctx context.Context) error {+ showSharedPreloadLibraries := `SELECT setting FROM pg_settings WHERE name = 'shared_preload_libraries';`++ sharedPreloadLibrariesRows, err := driver.db.QueryContext(ctx, showSharedPreloadLibraries)+ if err != nil {+ return util.FormatErrorWithQuery(err, showSharedPreloadLibraries)+ }+ defer sharedPreloadLibrariesRows.Close()+ for sharedPreloadLibrariesRows.Next() {+ var sharedPreloadLibraries string+ if err := sharedPreloadLibrariesRows.Scan(&sharedPreloadLibraries); err != nil {+ return err+ }+ if !strings.Contains(sharedPreloadLibraries, "pg_stat_statements") {+ return errors.New("pg_stat_statements is not loaded")+ }+ }+ if err := sharedPreloadLibrariesRows.Err(); err != nil {+ return util.FormatErrorWithQuery(err, showSharedPreloadLibraries)+ }++ showPGStatStatementsInfo := `SELECT dealloc, stats_reset FROM pg_stat_statements_info;`++ pgStatStatementsInfoRows, err := driver.db.QueryContext(ctx, showPGStatStatementsInfo)+ if err != nil {+ return util.FormatErrorWithQuery(err, showPGStatStatementsInfo)+ }+ defer pgStatStatementsInfoRows.Close()+ // no need to scan rows, just check if there is any row+ if !pgStatStatementsInfoRows.Next() {+ return errors.New("pg_stat_statements_info is empty")+ }+ if err := pgStatStatementsInfoRows.Err(); err != nil {+ return util.FormatErrorWithQuery(err, showPGStatStatementsInfo)+ }++ return nil}diff --git a/backend/runner/slowquerysync/syncer.go b/backend/runner/slowquerysync/syncer.goindex a52d00ddf3..1a0a52cc7d 100644--- a/backend/runner/slowquerysync/syncer.go+++ b/backend/runner/slowquerysync/syncer.go@@ -9,13 +9,17 @@ import ("github.com/pkg/errors""go.uber.org/zap"+ "google.golang.org/protobuf/types/known/durationpb""github.com/bytebase/bytebase/backend/common/log""github.com/bytebase/bytebase/backend/component/config""github.com/bytebase/bytebase/backend/component/dbfactory""github.com/bytebase/bytebase/backend/component/state"api "github.com/bytebase/bytebase/backend/legacyapi"+ "github.com/bytebase/bytebase/backend/plugin/db""github.com/bytebase/bytebase/backend/store"+ storepb "github.com/bytebase/bytebase/proto/generated-go/store"+ v1pb "github.com/bytebase/bytebase/proto/generated-go/v1")const (@@ -111,6 +115,162 @@ func (s *Syncer) syncInstanceSlowQuery(ctx context.Context, instance *store.Instreturn nil}+ switch instance.Engine {+ case db.MySQL:+ return s.syncMySQLSlowQuery(ctx, instance)+ case db.Postgres:+ return s.syncPostgreSQLSlowQuery(ctx, instance)+ default:+ return errors.Errorf("unsupported database engine: %s", instance.Engine)+ }+}++func (s *Syncer) syncPostgreSQLSlowQuery(ctx context.Context, instance *store.InstanceMessage) error {+ databases, err := s.store.ListDatabases(ctx, &store.FindDatabaseMessage{+ InstanceID: &instance.ResourceID,+ })+ if err != nil {+ return err+ }++ var firstDatabase string+ for _, database := range databases {+ if database.SyncState != api.OK {+ continue+ }+ if err := func() error {+ driver, err := s.dbFactory.GetAdminDatabaseDriver(ctx, instance, database.DatabaseName)+ if err != nil {+ return err+ }+ defer driver.Close(ctx)+ return driver.CheckSlowQueryLogEnabled(ctx)+ }(); err != nil {+ log.Warn("pg_stat_statements is not enabled",+ zap.String("instance", instance.ResourceID),+ zap.String("database", database.DatabaseName),+ zap.Int("databaseID", database.UID),+ zap.Error(err))+ }++ if firstDatabase == "" {+ firstDatabase = database.DatabaseName+ }+ }++ if firstDatabase == "" {+ return errors.Errorf("no database is available for slow query sync in instance %s", instance.ResourceID)+ }++ driver, err := s.dbFactory.GetAdminDatabaseDriver(ctx, instance, firstDatabase)+ if err != nil {+ return err+ }+ defer driver.Close(ctx)++ logMap, err := driver.SyncSlowQuery(ctx, time.Now() /* logDateTs is not used for postgresql */)+ if err != nil {+ return err+ }++ latestLogDate := getLatestLogTime(logMap)+ if latestLogDate.IsZero() {+ // Empty log, no need to sync.+ return nil+ }+ latestLogDate = latestLogDate.Truncate(24 * time.Hour)+ nextLogDate := latestLogDate.AddDate(0, 0, 1)++ for _, database := range databases {+ statistics, exists := logMap[database.DatabaseName]+ if !exists {+ continue+ }++ logs, err := s.store.ListSlowQuery(ctx, &store.ListSlowQueryMessage{+ InstanceUID: &instance.UID,+ DatabaseUID: &database.UID,+ StartLogDate: &latestLogDate,+ EndLogDate: &nextLogDate,+ })+ if err != nil {+ log.Warn("Failed to list slow query logs",+ zap.String("instance", instance.ResourceID),+ zap.String("database", database.DatabaseName),+ zap.Int("databaseID", database.UID),+ zap.Error(err))+ logs = nil+ }++ if len(logs) != 0 {+ statistics = pgMergeSlowQueryLog(statistics, logs)+ }+ if err := s.store.UpsertSlowLog(ctx, &store.UpsertSlowLogMessage{+ EnvironmentID: &instance.EnvironmentID,+ InstanceID: &instance.ResourceID,+ DatabaseName: database.DatabaseName,+ InstanceUID: instance.UID,+ LogDate: latestLogDate,+ SlowLog: statistics,+ UpdaterID: api.SystemBotID,+ }); err != nil {+ log.Warn("Failed to upsert slow query log",+ zap.String("instance", instance.ResourceID),+ zap.String("database", database.DatabaseName),+ zap.Int("databaseID", database.UID),+ zap.Error(err))+ }+ }++ return nil+}++func pgMergeSlowQueryLog(statistics *storepb.SlowQueryStatistics, logs []*v1pb.SlowQueryLog) *storepb.SlowQueryStatistics {+ status := make(map[string]*storepb.SlowQueryStatisticsItem)++ for _, item := range statistics.Items {+ status[item.SqlFingerprint] = item+ }++ for _, log := range logs {+ value, exists := status[log.Statistics.SqlFingerprint]+ if !exists {+ status[log.Statistics.SqlFingerprint] = &storepb.SlowQueryStatisticsItem{+ SqlFingerprint: log.Statistics.SqlFingerprint,+ Count: log.Statistics.Count,+ LatestLogTime: log.Statistics.LatestLogTime,+ TotalQueryTime: durationpb.New(log.Statistics.AverageQueryTime.AsDuration() * time.Duration(log.Statistics.Count)),+ MaximumQueryTime: log.Statistics.MaximumQueryTime,+ TotalRowsSent: log.Statistics.AverageRowsSent * log.Statistics.Count,+ }+ } else {+ value.Count += log.Statistics.Count+ totalQueryTime := log.Statistics.AverageQueryTime.AsDuration() * time.Duration(log.Statistics.Count)+ value.TotalQueryTime = durationpb.New(value.TotalQueryTime.AsDuration() + totalQueryTime)+ if value.MaximumQueryTime.AsDuration() < log.Statistics.MaximumQueryTime.AsDuration() {+ value.MaximumQueryTime = log.Statistics.MaximumQueryTime+ }+ value.TotalRowsSent += log.Statistics.AverageRowsSent * log.Statistics.Count+ }+ }++ var result []*storepb.SlowQueryStatisticsItem+ for _, item := range status {+ result = append(result, item)+ }+ return &storepb.SlowQueryStatistics{Items: result}+}++func getLatestLogTime(logMap map[string]*storepb.SlowQueryStatistics) time.Time {+ for _, log := range logMap {+ for _, item := range log.Items {+ return item.LatestLogTime.AsTime()+ }+ }+ return time.Time{}+}++func (s *Syncer) syncMySQLSlowQuery(ctx context.Context, instance *store.InstanceMessage) error {today := time.Now().Truncate(24 * time.Hour)earliestDate := today.AddDate(0, 0, -retentionCycle)diff --git a/backend/store/slow_query.go b/backend/store/slow_query.goindex a428f4db7d..0a10da842f 100644--- a/backend/store/slow_query.go+++ b/backend/store/slow_query.go@@ -182,8 +182,8 @@ func (*Store) listSlowQueryImpl(ctx context.Context, tx *Tx, list *ListSlowQueryfunc calculateStatistics(value *slowQueryLogValue) *v1pb.SlowQueryLog {result := value.logresult.Statistics.AverageQueryTime = durationpb.New(value.totalQueryTime / time.Duration(result.Statistics.Count))- result.Statistics.AverageRowsSent = int32(value.totalRowsSent / int64(result.Statistics.Count))- result.Statistics.AverageRowsExamined = int32(value.totalRowsExamined / int64(result.Statistics.Count))+ result.Statistics.AverageRowsSent = int64(value.totalRowsSent / result.Statistics.Count)+ result.Statistics.AverageRowsExamined = int64(value.totalRowsExamined / result.Statistics.Count)return result}diff --git a/frontend/src/types/proto/store/slow_query.ts b/frontend/src/types/proto/store/slow_query.tsindex 287860c4ef..ab49bdb1ca 100644--- a/frontend/src/types/proto/store/slow_query.ts+++ b/frontend/src/types/proto/store/slow_query.ts@@ -135,7 +135,7 @@ export const SlowQueryStatisticsItem = {writer.uint32(10).string(message.sqlFingerprint);}if (message.count !== 0) {- writer.uint32(16).int32(message.count);+ writer.uint32(16).int64(message.count);}if (message.latestLogTime !== undefined) {Timestamp.encode(toTimestamp(message.latestLogTime), writer.uint32(26).fork()).ldelim();@@ -150,13 +150,13 @@ export const SlowQueryStatisticsItem = {writer.uint32(48).int64(message.totalRowsSent);}if (message.maximumRowsSent !== 0) {- writer.uint32(56).int32(message.maximumRowsSent);+ writer.uint32(56).int64(message.maximumRowsSent);}if (message.totalRowsExamined !== 0) {writer.uint32(64).int64(message.totalRowsExamined);}if (message.maximumRowsExamined !== 0) {- writer.uint32(72).int32(message.maximumRowsExamined);+ writer.uint32(72).int64(message.maximumRowsExamined);}for (const v of message.samples) {SlowQueryDetails.encode(v!, writer.uint32(82).fork()).ldelim();@@ -183,7 +183,7 @@ export const SlowQueryStatisticsItem = {break;}- message.count = reader.int32();+ message.count = longToNumber(reader.int64() as Long);continue;case 3:if (tag != 26) {@@ -218,7 +218,7 @@ export const SlowQueryStatisticsItem = {break;}- message.maximumRowsSent = reader.int32();+ message.maximumRowsSent = longToNumber(reader.int64() as Long);continue;case 8:if (tag != 64) {@@ -232,7 +232,7 @@ export const SlowQueryStatisticsItem = {break;}- message.maximumRowsExamined = reader.int32();+ message.maximumRowsExamined = longToNumber(reader.int64() as Long);continue;case 10:if (tag != 82) {@@ -326,10 +326,10 @@ export const SlowQueryDetails = {Duration.encode(message.lockTime, writer.uint32(26).fork()).ldelim();}if (message.rowsSent !== 0) {- writer.uint32(32).int32(message.rowsSent);+ writer.uint32(32).int64(message.rowsSent);}if (message.rowsExamined !== 0) {- writer.uint32(40).int32(message.rowsExamined);+ writer.uint32(40).int64(message.rowsExamined);}if (message.sqlText !== "") {writer.uint32(50).string(message.sqlText);@@ -370,14 +370,14 @@ export const SlowQueryDetails = {break;}- message.rowsSent = reader.int32();+ message.rowsSent = longToNumber(reader.int64() as Long);continue;case 5:if (tag != 40) {break;}- message.rowsExamined = reader.int32();+ message.rowsExamined = longToNumber(reader.int64() as Long);continue;case 6:if (tag != 50) {diff --git a/frontend/src/types/proto/v1/database_service.ts b/frontend/src/types/proto/v1/database_service.tsindex bf26ffa141..4d0d7bd177 100644--- a/frontend/src/types/proto/v1/database_service.ts+++ b/frontend/src/types/proto/v1/database_service.ts@@ -3538,7 +3538,7 @@ export const SlowQueryStatistics = {writer.uint32(10).string(message.sqlFingerprint);}if (message.count !== 0) {- writer.uint32(16).int32(message.count);+ writer.uint32(16).int64(message.count);}if (message.latestLogTime !== undefined) {Timestamp.encode(toTimestamp(message.latestLogTime), writer.uint32(26).fork()).ldelim();@@ -3550,16 +3550,16 @@ export const SlowQueryStatistics = {Duration.encode(message.maximumQueryTime, writer.uint32(42).fork()).ldelim();}if (message.averageRowsSent !== 0) {- writer.uint32(48).int32(message.averageRowsSent);+ writer.uint32(48).int64(message.averageRowsSent);}if (message.maximumRowsSent !== 0) {- writer.uint32(56).int32(message.maximumRowsSent);+ writer.uint32(56).int64(message.maximumRowsSent);}if (message.averageRowsExamined !== 0) {- writer.uint32(64).int32(message.averageRowsExamined);+ writer.uint32(64).int64(message.averageRowsExamined);}if (message.maximumRowsExamined !== 0) {- writer.uint32(72).int32(message.maximumRowsExamined);+ writer.uint32(72).int64(message.maximumRowsExamined);}for (const v of message.samples) {SlowQueryDetails.encode(v!, writer.uint32(82).fork()).ldelim();@@ -3586,7 +3586,7 @@ export const SlowQueryStatistics = {break;}- message.count = reader.int32();+ message.count = longToNumber(reader.int64() as Long);continue;case 3:if (tag != 26) {@@ -3614,28 +3614,28 @@ export const SlowQueryStatistics = {break;}- message.averageRowsSent = reader.int32();+ message.averageRowsSent = longToNumber(reader.int64() as Long);continue;case 7:if (tag != 56) {break;}- message.maximumRowsSent = reader.int32();+ message.maximumRowsSent = longToNumber(reader.int64() as Long);continue;case 8:if (tag != 64) {break;}- message.averageRowsExamined = reader.int32();+ message.averageRowsExamined = longToNumber(reader.int64() as Long);continue;case 9:if (tag != 72) {break;}- message.maximumRowsExamined = reader.int32();+ message.maximumRowsExamined = longToNumber(reader.int64() as Long);continue;case 10:if (tag != 82) {@@ -3729,10 +3729,10 @@ export const SlowQueryDetails = {Duration.encode(message.lockTime, writer.uint32(26).fork()).ldelim();}if (message.rowsSent !== 0) {- writer.uint32(32).int32(message.rowsSent);+ writer.uint32(32).int64(message.rowsSent);}if (message.rowsExamined !== 0) {- writer.uint32(40).int32(message.rowsExamined);+ writer.uint32(40).int64(message.rowsExamined);}if (message.sqlText !== "") {writer.uint32(50).string(message.sqlText);@@ -3773,14 +3773,14 @@ export const SlowQueryDetails = {break;}- message.rowsSent = reader.int32();+ message.rowsSent = longToNumber(reader.int64() as Long);continue;case 5:if (tag != 40) {break;}- message.rowsExamined = reader.int32();+ message.rowsExamined = longToNumber(reader.int64() as Long);continue;case 6:if (tag != 50) {diff --git a/frontend/src/utils/instance.ts b/frontend/src/utils/instance.tsindex cd7325219b..36184a3810 100644--- a/frontend/src/utils/instance.ts+++ b/frontend/src/utils/instance.ts@@ -155,6 +155,9 @@ export const instanceSupportSlowQuery = (instance: Instance) => {if (engine === "MYSQL") {return semverCompare(instance.engineVersion, "5.7", "gte");}+ if (engine === "POSTGRES") {+ return true;+ }return false;};diff --git a/proto/gen/grpc-doc/store/README.md b/proto/gen/grpc-doc/store/README.mdindex bf0e4c8d14..bd0279b745 100644--- a/proto/gen/grpc-doc/store/README.md+++ b/proto/gen/grpc-doc/store/README.md@@ -972,8 +972,8 @@ SlowQueryDetails is the details of a slow query.| start_time | [google.protobuf.Timestamp](#google-protobuf-Timestamp) | | start_time is the start time of the slow query. || query_time | [google.protobuf.Duration](#google-protobuf-Duration) | | query_time is the query time of the slow query. || lock_time | [google.protobuf.Duration](#google-protobuf-Duration) | | lock_time is the lock time of the slow query. |-| rows_sent | [int32](#int32) | | rows_sent is the number of rows sent by the slow query. |-| rows_examined | [int32](#int32) | | rows_examined is the number of rows examined by the slow query. |+| rows_sent | [int64](#int64) | | rows_sent is the number of rows sent by the slow query. |+| rows_examined | [int64](#int64) | | rows_examined is the number of rows examined by the slow query. || sql_text | [string](#string) | | sql_text is the SQL text of the slow query. |@@ -1005,14 +1005,14 @@ SlowQueryStatisticsItem is the item of slow query statistics.| Field | Type | Label | Description || ----- | ---- | ----- | ----------- || sql_fingerprint | [string](#string) | | sql_fingerprint is the fingerprint of the slow query. |-| count | [int32](#int32) | | count is the number of slow queries with the same fingerprint. |+| count | [int64](#int64) | | count is the number of slow queries with the same fingerprint. || latest_log_time | [google.protobuf.Timestamp](#google-protobuf-Timestamp) | | latest_log_time is the time of the latest slow query with the same fingerprint. || total_query_time | [google.protobuf.Duration](#google-protobuf-Duration) | | The total query time of the slow query log. || maximum_query_time | [google.protobuf.Duration](#google-protobuf-Duration) | | The maximum query time of the slow query log. || total_rows_sent | [int64](#int64) | | The total rows sent of the slow query log. |-| maximum_rows_sent | [int32](#int32) | | The maximum rows sent of the slow query log. |+| maximum_rows_sent | [int64](#int64) | | The maximum rows sent of the slow query log. || total_rows_examined | [int64](#int64) | | The total rows examined of the slow query log. |-| maximum_rows_examined | [int32](#int32) | | The maximum rows examined of the slow query log. |+| maximum_rows_examined | [int64](#int64) | | The maximum rows examined of the slow query log. || samples | [SlowQueryDetails](#bytebase-store-SlowQueryDetails) | repeated | samples are the details of the sample slow queries with the same fingerprint. |diff --git a/proto/gen/grpc-doc/v1/README.md b/proto/gen/grpc-doc/v1/README.mdindex 1fcdaec27e..f8482d29ca 100644--- a/proto/gen/grpc-doc/v1/README.md+++ b/proto/gen/grpc-doc/v1/README.md@@ -1563,8 +1563,8 @@ SlowQueryDetails is the details of the slow query log.| start_time | [google.protobuf.Timestamp](#google-protobuf-Timestamp) | | The start time of the slow query log. || query_time | [google.protobuf.Duration](#google-protobuf-Duration) | | The query time of the slow query log. || lock_time | [google.protobuf.Duration](#google-protobuf-Duration) | | The lock time of the slow query log. |-| rows_sent | [int32](#int32) | | The rows sent of the slow query log. |-| rows_examined | [int32](#int32) | | The rows examined of the slow query log. |+| rows_sent | [int64](#int64) | | The rows sent of the slow query log. |+| rows_examined | [int64](#int64) | | The rows examined of the slow query log. || sql_text | [string](#string) | | The sql text of the slow query log. |@@ -1598,14 +1598,14 @@ SlowQueryStatistics is the statistics of the slow query log.| Field | Type | Label | Description || ----- | ---- | ----- | ----------- || sql_fingerprint | [string](#string) | | The fingerprint of the slow query log. |-| count | [int32](#int32) | | The count of the slow query log. |+| count | [int64](#int64) | | The count of the slow query log. || latest_log_time | [google.protobuf.Timestamp](#google-protobuf-Timestamp) | | The latest log time of the slow query log. || average_query_time | [google.protobuf.Duration](#google-protobuf-Duration) | | The average query time of the slow query log. || maximum_query_time | [google.protobuf.Duration](#google-protobuf-Duration) | | The maximum query time of the slow query log. |-| average_rows_sent | [int32](#int32) | | The average rows sent of the slow query log. |-| maximum_rows_sent | [int32](#int32) | | The maximum rows sent of the slow query log. |-| average_rows_examined | [int32](#int32) | | The average rows examined of the slow query log. |-| maximum_rows_examined | [int32](#int32) | | The maximum rows examined of the slow query log. |+| average_rows_sent | [int64](#int64) | | The average rows sent of the slow query log. |+| maximum_rows_sent | [int64](#int64) | | The maximum rows sent of the slow query log. |+| average_rows_examined | [int64](#int64) | | The average rows examined of the slow query log. |+| maximum_rows_examined | [int64](#int64) | | The maximum rows examined of the slow query log. || samples | [SlowQueryDetails](#bytebase-v1-SlowQueryDetails) | repeated | Samples are details of the sample slow query logs with the same fingerprint. |diff --git a/proto/generated-go/store/slow_query.pb.go b/proto/generated-go/store/slow_query.pb.goindex d9cf3f6d1e..473edf0f20 100644--- a/proto/generated-go/store/slow_query.pb.go+++ b/proto/generated-go/store/slow_query.pb.go@@ -80,7 +80,7 @@ type SlowQueryStatisticsItem struct {// sql_fingerprint is the fingerprint of the slow query.SqlFingerprint string `protobuf:"bytes,1,opt,name=sql_fingerprint,json=sqlFingerprint,proto3" json:"sql_fingerprint,omitempty"`// count is the number of slow queries with the same fingerprint.- Count int32 `protobuf:"varint,2,opt,name=count,proto3" json:"count,omitempty"`+ Count int64 `protobuf:"varint,2,opt,name=count,proto3" json:"count,omitempty"`// latest_log_time is the time of the latest slow query with the same fingerprint.LatestLogTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=latest_log_time,json=latestLogTime,proto3" json:"latest_log_time,omitempty"`// The total query time of the slow query log.@@ -90,11 +90,11 @@ type SlowQueryStatisticsItem struct {// The total rows sent of the slow query log.TotalRowsSent int64 `protobuf:"varint,6,opt,name=total_rows_sent,json=totalRowsSent,proto3" json:"total_rows_sent,omitempty"`// The maximum rows sent of the slow query log.- MaximumRowsSent int32 `protobuf:"varint,7,opt,name=maximum_rows_sent,json=maximumRowsSent,proto3" json:"maximum_rows_sent,omitempty"`+ MaximumRowsSent int64 `protobuf:"varint,7,opt,name=maximum_rows_sent,json=maximumRowsSent,proto3" json:"maximum_rows_sent,omitempty"`// The total rows examined of the slow query log.TotalRowsExamined int64 `protobuf:"varint,8,opt,name=total_rows_examined,json=totalRowsExamined,proto3" json:"total_rows_examined,omitempty"`// The maximum rows examined of the slow query log.- MaximumRowsExamined int32 `protobuf:"varint,9,opt,name=maximum_rows_examined,json=maximumRowsExamined,proto3" json:"maximum_rows_examined,omitempty"`+ MaximumRowsExamined int64 `protobuf:"varint,9,opt,name=maximum_rows_examined,json=maximumRowsExamined,proto3" json:"maximum_rows_examined,omitempty"`// samples are the details of the sample slow queries with the same fingerprint.Samples []*SlowQueryDetails `protobuf:"bytes,10,rep,name=samples,proto3" json:"samples,omitempty"`}@@ -138,7 +138,7 @@ func (x *SlowQueryStatisticsItem) GetSqlFingerprint() string {return ""}-func (x *SlowQueryStatisticsItem) GetCount() int32 {+func (x *SlowQueryStatisticsItem) GetCount() int64 {if x != nil {return x.Count}@@ -173,7 +173,7 @@ func (x *SlowQueryStatisticsItem) GetTotalRowsSent() int64 {return 0}-func (x *SlowQueryStatisticsItem) GetMaximumRowsSent() int32 {+func (x *SlowQueryStatisticsItem) GetMaximumRowsSent() int64 {if x != nil {return x.MaximumRowsSent}@@ -187,7 +187,7 @@ func (x *SlowQueryStatisticsItem) GetTotalRowsExamined() int64 {return 0}-func (x *SlowQueryStatisticsItem) GetMaximumRowsExamined() int32 {+func (x *SlowQueryStatisticsItem) GetMaximumRowsExamined() int64 {if x != nil {return x.MaximumRowsExamined}@@ -214,9 +214,9 @@ type SlowQueryDetails struct {// lock_time is the lock time of the slow query.LockTime *durationpb.Duration `protobuf:"bytes,3,opt,name=lock_time,json=lockTime,proto3" json:"lock_time,omitempty"`// rows_sent is the number of rows sent by the slow query.- RowsSent int32 `protobuf:"varint,4,opt,name=rows_sent,json=rowsSent,proto3" json:"rows_sent,omitempty"`+ RowsSent int64 `protobuf:"varint,4,opt,name=rows_sent,json=rowsSent,proto3" json:"rows_sent,omitempty"`// rows_examined is the number of rows examined by the slow query.- RowsExamined int32 `protobuf:"varint,5,opt,name=rows_examined,json=rowsExamined,proto3" json:"rows_examined,omitempty"`+ RowsExamined int64 `protobuf:"varint,5,opt,name=rows_examined,json=rowsExamined,proto3" json:"rows_examined,omitempty"`// sql_text is the SQL text of the slow query.SqlText string `protobuf:"bytes,6,opt,name=sql_text,json=sqlText,proto3" json:"sql_text,omitempty"`}@@ -274,14 +274,14 @@ func (x *SlowQueryDetails) GetLockTime() *durationpb.Duration {return nil}-func (x *SlowQueryDetails) GetRowsSent() int32 {+func (x *SlowQueryDetails) GetRowsSent() int64 {if x != nil {return x.RowsSent}return 0}-func (x *SlowQueryDetails) GetRowsExamined() int32 {+func (x *SlowQueryDetails) GetRowsExamined() int64 {if x != nil {return x.RowsExamined}@@ -315,7 +315,7 @@ var file_store_slow_query_proto_rawDesc = []byte{0x71, 0x6c, 0x5f, 0x66, 0x69, 0x6e, 0x67, 0x65, 0x72, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x18, 0x01,0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x73, 0x71, 0x6c, 0x46, 0x69, 0x6e, 0x67, 0x65, 0x72, 0x70,0x72, 0x69, 0x6e, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20,- 0x01, 0x28, 0x05, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x42, 0x0a, 0x0f, 0x6c, 0x61,+ 0x01, 0x28, 0x03, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x42, 0x0a, 0x0f, 0x6c, 0x61,0x74, 0x65, 0x73, 0x74, 0x5f, 0x6c, 0x6f, 0x67, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20,0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f,0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52,@@ -332,13 +332,13 @@ var file_store_slow_query_proto_rawDesc = []byte{0x74, 0x6f, 0x74, 0x61, 0x6c, 0x5f, 0x72, 0x6f, 0x77, 0x73, 0x5f, 0x73, 0x65, 0x6e, 0x74, 0x18,0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x52, 0x6f, 0x77, 0x73,0x53, 0x65, 0x6e, 0x74, 0x12, 0x2a, 0x0a, 0x11, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x5f,- 0x72, 0x6f, 0x77, 0x73, 0x5f, 0x73, 0x65, 0x6e, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52,+ 0x72, 0x6f, 0x77, 0x73, 0x5f, 0x73, 0x65, 0x6e, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x03, 0x52,0x0f, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x52, 0x6f, 0x77, 0x73, 0x53, 0x65, 0x6e, 0x74,0x12, 0x2e, 0x0a, 0x13, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x5f, 0x72, 0x6f, 0x77, 0x73, 0x5f, 0x65,0x78, 0x61, 0x6d, 0x69, 0x6e, 0x65, 0x64, 0x18, 0x08, 0x20, 0x01, 0x28, 0x03, 0x52, 0x11, 0x74,0x6f, 0x74, 0x61, 0x6c, 0x52, 0x6f, 0x77, 0x73, 0x45, 0x78, 0x61, 0x6d, 0x69, 0x6e, 0x65, 0x64,0x12, 0x32, 0x0a, 0x15, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x5f, 0x72, 0x6f, 0x77, 0x73,- 0x5f, 0x65, 0x78, 0x61, 0x6d, 0x69, 0x6e, 0x65, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x05, 0x52,+ 0x5f, 0x65, 0x78, 0x61, 0x6d, 0x69, 0x6e, 0x65, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x03, 0x52,0x13, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x52, 0x6f, 0x77, 0x73, 0x45, 0x78, 0x61, 0x6d,0x69, 0x6e, 0x65, 0x64, 0x12, 0x3a, 0x0a, 0x07, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x18,0x0a, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65,@@ -357,9 +357,9 @@ var file_store_slow_query_proto_rawDesc = []byte{0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e,0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x08, 0x6c, 0x6f, 0x63, 0x6b, 0x54, 0x69,0x6d, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x72, 0x6f, 0x77, 0x73, 0x5f, 0x73, 0x65, 0x6e, 0x74, 0x18,- 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x72, 0x6f, 0x77, 0x73, 0x53, 0x65, 0x6e, 0x74, 0x12,+ 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x72, 0x6f, 0x77, 0x73, 0x53, 0x65, 0x6e, 0x74, 0x12,0x23, 0x0a, 0x0d, 0x72, 0x6f, 0x77, 0x73, 0x5f, 0x65, 0x78, 0x61, 0x6d, 0x69, 0x6e, 0x65, 0x64,- 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0c, 0x72, 0x6f, 0x77, 0x73, 0x45, 0x78, 0x61, 0x6d,+ 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0c, 0x72, 0x6f, 0x77, 0x73, 0x45, 0x78, 0x61, 0x6d,0x69, 0x6e, 0x65, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x73, 0x71, 0x6c, 0x5f, 0x74, 0x65, 0x78, 0x74,0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x71, 0x6c, 0x54, 0x65, 0x78, 0x74, 0x42,0x14, 0x5a, 0x12, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x64, 0x2d, 0x67, 0x6f, 0x2f,diff --git a/proto/generated-go/v1/database_service.pb.go b/proto/generated-go/v1/database_service.pb.goindex d85d2f04e5..0d80094023 100644--- a/proto/generated-go/v1/database_service.pb.go+++ b/proto/generated-go/v1/database_service.pb.go@@ -2348,7 +2348,7 @@ type SlowQueryStatistics struct {// The fingerprint of the slow query log.SqlFingerprint string `protobuf:"bytes,1,opt,name=sql_fingerprint,json=sqlFingerprint,proto3" json:"sql_fingerprint,omitempty"`// The count of the slow query log.- Count int32 `protobuf:"varint,2,opt,name=count,proto3" json:"count,omitempty"`+ Count int64 `protobuf:"varint,2,opt,name=count,proto3" json:"count,omitempty"`// The latest log time of the slow query log.LatestLogTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=latest_log_time,json=latestLogTime,proto3" json:"latest_log_time,omitempty"`// The average query time of the slow query log.@@ -2356,13 +2356,13 @@ type SlowQueryStatistics struct {// The maximum query time of the slow query log.MaximumQueryTime *durationpb.Duration `protobuf:"bytes,5,opt,name=maximum_query_time,json=maximumQueryTime,proto3" json:"maximum_query_time,omitempty"`// The average rows sent of the slow query log.- AverageRowsSent int32 `protobuf:"varint,6,opt,name=average_rows_sent,json=averageRowsSent,proto3" json:"average_rows_sent,omitempty"`+ AverageRowsSent int64 `protobuf:"varint,6,opt,name=average_rows_sent,json=averageRowsSent,proto3" json:"average_rows_sent,omitempty"`// The maximum rows sent of the slow query log.- MaximumRowsSent int32 `protobuf:"varint,7,opt,name=maximum_rows_sent,json=maximumRowsSent,proto3" json:"maximum_rows_sent,omitempty"`+ MaximumRowsSent int64 `protobuf:"varint,7,opt,name=maximum_rows_sent,json=maximumRowsSent,proto3" json:"maximum_rows_sent,omitempty"`// The average rows examined of the slow query log.- AverageRowsExamined int32 `protobuf:"varint,8,opt,name=average_rows_examined,json=averageRowsExamined,proto3" json:"average_rows_examined,omitempty"`+ AverageRowsExamined int64 `protobuf:"varint,8,opt,name=average_rows_examined,json=averageRowsExamined,proto3" json:"average_rows_examined,omitempty"`// The maximum rows examined of the slow query log.- MaximumRowsExamined int32 `protobuf:"varint,9,opt,name=maximum_rows_examined,json=maximumRowsExamined,proto3" json:"maximum_rows_examined,omitempty"`+ MaximumRowsExamined int64 `protobuf:"varint,9,opt,name=maximum_rows_examined,json=maximumRowsExamined,proto3" json:"maximum_rows_examined,omitempty"`// Samples are details of the sample slow query logs with the same fingerprint.Samples []*SlowQueryDetails `protobuf:"bytes,10,rep,name=samples,proto3" json:"samples,omitempty"`}@@ -2406,7 +2406,7 @@ func (x *SlowQueryStatistics) GetSqlFingerprint() string {return ""}-func (x *SlowQueryStatistics) GetCount() int32 {+func (x *SlowQueryStatistics) GetCount() int64 {if x != nil {return x.Count}@@ -2434,28 +2434,28 @@ func (x *SlowQueryStatistics) GetMaximumQueryTime() *durationpb.Duration {return nil}-func (x *SlowQueryStatistics) GetAverageRowsSent() int32 {+func (x *SlowQueryStatistics) GetAverageRowsSent() int64 {if x != nil {return x.AverageRowsSent}return 0}-func (x *SlowQueryStatistics) GetMaximumRowsSent() int32 {+func (x *SlowQueryStatistics) GetMaximumRowsSent() int64 {if x != nil {return x.MaximumRowsSent}return 0}-func (x *SlowQueryStatistics) GetAverageRowsExamined() int32 {+func (x *SlowQueryStatistics) GetAverageRowsExamined() int64 {if x != nil {return x.AverageRowsExamined}return 0}-func (x *SlowQueryStatistics) GetMaximumRowsExamined() int32 {+func (x *SlowQueryStatistics) GetMaximumRowsExamined() int64 {if x != nil {return x.MaximumRowsExamined}@@ -2482,9 +2482,9 @@ type SlowQueryDetails struct {// The lock time of the slow query log.LockTime *durationpb.Duration `protobuf:"bytes,3,opt,name=lock_time,json=lockTime,proto3" json:"lock_time,omitempty"`// The rows sent of the slow query log.- RowsSent int32 `protobuf:"varint,4,opt,name=rows_sent,json=rowsSent,proto3" json:"rows_sent,omitempty"`+ RowsSent int64 `protobuf:"varint,4,opt,name=rows_sent,json=rowsSent,proto3" json:"rows_sent,omitempty"`// The rows examined of the slow query log.- RowsExamined int32 `protobuf:"varint,5,opt,name=rows_examined,json=rowsExamined,proto3" json:"rows_examined,omitempty"`+ RowsExamined int64 `protobuf:"varint,5,opt,name=rows_examined,json=rowsExamined,proto3" json:"rows_examined,omitempty"`// The sql text of the slow query log.SqlText string `protobuf:"bytes,6,opt,name=sql_text,json=sqlText,proto3" json:"sql_text,omitempty"`}@@ -2542,14 +2542,14 @@ func (x *SlowQueryDetails) GetLockTime() *durationpb.Duration {return nil}-func (x *SlowQueryDetails) GetRowsSent() int32 {+func (x *SlowQueryDetails) GetRowsSent() int64 {if x != nil {return x.RowsSent}return 0}-func (x *SlowQueryDetails) GetRowsExamined() int32 {+func (x *SlowQueryDetails) GetRowsExamined() int64 {if x != nil {return x.RowsExamined}@@ -2886,7 +2886,7 @@ var file_v1_database_service_proto_rawDesc = []byte{0x73, 0x74, 0x69, 0x63, 0x73, 0x12, 0x27, 0x0a, 0x0f, 0x73, 0x71, 0x6c, 0x5f, 0x66, 0x69, 0x6e,0x67, 0x65, 0x72, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e,0x73, 0x71, 0x6c, 0x46, 0x69, 0x6e, 0x67, 0x65, 0x72, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x12, 0x14,- 0x0a, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x63,+ 0x0a, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x63,0x6f, 0x75, 0x6e, 0x74, 0x12, 0x42, 0x0a, 0x0f, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x6c,0x6f, 0x67, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e,0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e,@@ -2902,16 +2902,16 @@ var file_v1_database_service_proto_rawDesc = []byte{0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x10, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75,0x6d, 0x51, 0x75, 0x65, 0x72, 0x79, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x2a, 0x0a, 0x11, 0x61, 0x76,0x65, 0x72, 0x61, 0x67, 0x65, 0x5f, 0x72, 0x6f, 0x77, 0x73, 0x5f, 0x73, 0x65, 0x6e, 0x74, 0x18,- 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0f, 0x61, 0x76, 0x65, 0x72, 0x61, 0x67, 0x65, 0x52, 0x6f,+ 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0f, 0x61, 0x76, 0x65, 0x72, 0x61, 0x67, 0x65, 0x52, 0x6f,0x77, 0x73, 0x53, 0x65, 0x6e, 0x74, 0x12, 0x2a, 0x0a, 0x11, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75,0x6d, 0x5f, 0x72, 0x6f, 0x77, 0x73, 0x5f, 0x73, 0x65, 0x6e, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28,- 0x05, 0x52, 0x0f, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x52, 0x6f, 0x77, 0x73, 0x53, 0x65,+ 0x03, 0x52, 0x0f, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x52, 0x6f, 0x77, 0x73, 0x53, 0x65,0x6e, 0x74, 0x12, 0x32, 0x0a, 0x15, 0x61, 0x76, 0x65, 0x72, 0x61, 0x67, 0x65, 0x5f, 0x72, 0x6f,0x77, 0x73, 0x5f, 0x65, 0x78, 0x61, 0x6d, 0x69, 0x6e, 0x65, 0x64, 0x18, 0x08, 0x20, 0x01, 0x28,- 0x05, 0x52, 0x13, 0x61, 0x76, 0x65, 0x72, 0x61, 0x67, 0x65, 0x52, 0x6f, 0x77, 0x73, 0x45, 0x78,+ 0x03, 0x52, 0x13, 0x61, 0x76, 0x65, 0x72, 0x61, 0x67, 0x65, 0x52, 0x6f, 0x77, 0x73, 0x45, 0x78,0x61, 0x6d, 0x69, 0x6e, 0x65, 0x64, 0x12, 0x32, 0x0a, 0x15, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75,0x6d, 0x5f, 0x72, 0x6f, 0x77, 0x73, 0x5f, 0x65, 0x78, 0x61, 0x6d, 0x69, 0x6e, 0x65, 0x64, 0x18,- 0x09, 0x20, 0x01, 0x28, 0x05, 0x52, 0x13, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x52, 0x6f,+ 0x09, 0x20, 0x01, 0x28, 0x03, 0x52, 0x13, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x52, 0x6f,0x77, 0x73, 0x45, 0x78, 0x61, 0x6d, 0x69, 0x6e, 0x65, 0x64, 0x12, 0x37, 0x0a, 0x07, 0x73, 0x61,0x6d, 0x70, 0x6c, 0x65, 0x73, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x62, 0x79,0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x6c, 0x6f, 0x77, 0x51, 0x75,@@ -2929,9 +2929,9 @@ var file_v1_database_service_proto_rawDesc = []byte{0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62,0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x08, 0x6c, 0x6f, 0x63,0x6b, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x72, 0x6f, 0x77, 0x73, 0x5f, 0x73, 0x65,- 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x72, 0x6f, 0x77, 0x73, 0x53, 0x65,+ 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x72, 0x6f, 0x77, 0x73, 0x53, 0x65,0x6e, 0x74, 0x12, 0x23, 0x0a, 0x0d, 0x72, 0x6f, 0x77, 0x73, 0x5f, 0x65, 0x78, 0x61, 0x6d, 0x69,- 0x6e, 0x65, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0c, 0x72, 0x6f, 0x77, 0x73, 0x45,+ 0x6e, 0x65, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0c, 0x72, 0x6f, 0x77, 0x73, 0x45,0x78, 0x61, 0x6d, 0x69, 0x6e, 0x65, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x73, 0x71, 0x6c, 0x5f, 0x74,0x65, 0x78, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x71, 0x6c, 0x54, 0x65,0x78, 0x74, 0x32, 0x98, 0x0e, 0x0a, 0x0f, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x53,diff --git a/proto/store/slow_query.proto b/proto/store/slow_query.protoindex 1a79cd8ad4..9ea4bf3a18 100644--- a/proto/store/slow_query.proto+++ b/proto/store/slow_query.proto@@ -19,7 +19,7 @@ message SlowQueryStatisticsItem {string sql_fingerprint = 1;// count is the number of slow queries with the same fingerprint.- int32 count = 2;+ int64 count = 2;// latest_log_time is the time of the latest slow query with the same fingerprint.google.protobuf.Timestamp latest_log_time = 3;@@ -34,13 +34,13 @@ message SlowQueryStatisticsItem {int64 total_rows_sent = 6;// The maximum rows sent of the slow query log.- int32 maximum_rows_sent = 7;+ int64 maximum_rows_sent = 7;// The total rows examined of the slow query log.int64 total_rows_examined = 8;// The maximum rows examined of the slow query log.- int32 maximum_rows_examined = 9;+ int64 maximum_rows_examined = 9;// samples are the details of the sample slow queries with the same fingerprint.repeated SlowQueryDetails samples = 10;@@ -58,10 +58,10 @@ message SlowQueryDetails {google.protobuf.Duration lock_time = 3;// rows_sent is the number of rows sent by the slow query.- int32 rows_sent = 4;+ int64 rows_sent = 4;// rows_examined is the number of rows examined by the slow query.- int32 rows_examined = 5;+ int64 rows_examined = 5;// sql_text is the SQL text of the slow query.string sql_text = 6;diff --git a/proto/v1/database_service.proto b/proto/v1/database_service.protoindex a72509f8ac..327e60cbc9 100644--- a/proto/v1/database_service.proto+++ b/proto/v1/database_service.proto@@ -570,7 +570,7 @@ message SlowQueryStatistics {string sql_fingerprint = 1;// The count of the slow query log.- int32 count = 2;+ int64 count = 2;// The latest log time of the slow query log.google.protobuf.Timestamp latest_log_time = 3;@@ -582,16 +582,16 @@ message SlowQueryStatistics {google.protobuf.Duration maximum_query_time = 5;// The average rows sent of the slow query log.- int32 average_rows_sent = 6;+ int64 average_rows_sent = 6;// The maximum rows sent of the slow query log.- int32 maximum_rows_sent = 7;+ int64 maximum_rows_sent = 7;// The average rows examined of the slow query log.- int32 average_rows_examined = 8;+ int64 average_rows_examined = 8;// The maximum rows examined of the slow query log.- int32 maximum_rows_examined = 9;+ int64 maximum_rows_examined = 9;// Samples are details of the sample slow query logs with the same fingerprint.repeated SlowQueryDetails samples = 10;@@ -609,10 +609,10 @@ message SlowQueryDetails {google.protobuf.Duration lock_time = 3;// The rows sent of the slow query log.- int32 rows_sent = 4;+ int64 rows_sent = 4;// The rows examined of the slow query log.- int32 rows_examined = 5;+ int64 rows_examined = 5;// The sql text of the slow query log.string sql_text = 6;