Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

feat(schema): add slow_query table (#5355)

rebelice326a00e5c5f4
diff --git a/backend/store/migration/dev/20230404000000##slow_query_table.sql b/backend/store/migration/dev/20230404000000##slow_query_table.sql
new file mode 100644
index 0000000000..3cb2f81ab7
--- /dev/null
+++ b/backend/store/migration/dev/20230404000000##slow_query_table.sql
@@ -0,0 +1,29 @@
+-- slow_query stores slow query statistics for each database.
+CREATE TABLE slow_query (
+ id SERIAL PRIMARY KEY,
+ row_status row_status NOT NULL DEFAULT 'NORMAL',
+ creator_id INTEGER NOT NULL REFERENCES principal (id),
+ created_ts BIGINT NOT NULL DEFAULT extract(epoch from now()),
+ updater_id INTEGER NOT NULL REFERENCES principal (id),
+ -- updated_ts is used to identify the latest timestamp for syncing slow query logs.
+ updated_ts BIGINT NOT NULL DEFAULT extract(epoch from now()),
+ -- In MySQL, users can query without specifying a database. In this case, instance_id is used to identify the instance.
+ instance_id INTEGER NOT NULL REFERENCES instance (id),
+ -- In MySQL, users can query without specifying a database. In this case, database_id is NULL.
+ database_id INTEGER NULL REFERENCES db (id),
+ -- It's hard to store all slow query logs, so the slow query is aggregated by day and database.
+ log_date_ts INTEGER NOT NULL,
+ -- It's hard to store all slow query logs, we sample the slow query log and store the part of them as details.
+ slow_query_statistics JSONB NOT NULL DEFAULT '{}'
+);
+
+-- The slow query log is aggregated by day and database and we usually query the slow query log by day and database.
+CREATE UNIQUE INDEX uk_slow_query_database_id_log_date_ts ON slow_query (database_id, log_date_ts);
+
+ALTER SEQUENCE slow_query_id_seq RESTART WITH 101;
+
+CREATE TRIGGER update_slow_query_updated_ts
+BEFORE
+UPDATE
+ ON slow_query FOR EACH ROW
+EXECUTE FUNCTION trigger_update_updated_ts();
diff --git a/backend/store/migration/dev/LATEST.sql b/backend/store/migration/dev/LATEST.sql
index ef54717351..8c6c54c7af 100644
--- a/backend/store/migration/dev/LATEST.sql
+++ b/backend/store/migration/dev/LATEST.sql
@@ -1127,3 +1127,33 @@ BEFORE
UPDATE
ON risk FOR EACH ROW
EXECUTE FUNCTION trigger_update_updated_ts();
+
+-- slow_query stores slow query statistics for each database.
+CREATE TABLE slow_query (
+ id SERIAL PRIMARY KEY,
+ row_status row_status NOT NULL DEFAULT 'NORMAL',
+ creator_id INTEGER NOT NULL REFERENCES principal (id),
+ created_ts BIGINT NOT NULL DEFAULT extract(epoch from now()),
+ updater_id INTEGER NOT NULL REFERENCES principal (id),
+ -- updated_ts is used to identify the latest timestamp for syncing slow query logs.
+ updated_ts BIGINT NOT NULL DEFAULT extract(epoch from now()),
+ -- In MySQL, users can query without specifying a database. In this case, instance_id is used to identify the instance.
+ instance_id INTEGER NOT NULL REFERENCES instance (id),
+ -- In MySQL, users can query without specifying a database. In this case, database_id is NULL.
+ database_id INTEGER NULL REFERENCES db (id),
+ -- It's hard to store all slow query logs, so the slow query is aggregated by day and database.
+ log_date_ts INTEGER NOT NULL,
+ -- It's hard to store all slow query logs, we sample the slow query log and store the part of them as details.
+ slow_query_statistics JSONB NOT NULL DEFAULT '{}'
+);
+
+-- The slow query log is aggregated by day and database and we usually query the slow query log by day and database.
+CREATE UNIQUE INDEX uk_slow_query_database_id_log_date_ts ON slow_query (database_id, log_date_ts);
+
+ALTER SEQUENCE slow_query_id_seq RESTART WITH 101;
+
+CREATE TRIGGER update_slow_query_updated_ts
+BEFORE
+UPDATE
+ ON slow_query FOR EACH ROW
+EXECUTE FUNCTION trigger_update_updated_ts();
diff --git a/frontend/src/types/proto/store/slow_query.ts b/frontend/src/types/proto/store/slow_query.ts
new file mode 100644
index 0000000000..be678c2b63
--- /dev/null
+++ b/frontend/src/types/proto/store/slow_query.ts
@@ -0,0 +1,296 @@
+/* eslint-disable */
+import * as _m0 from "protobufjs/minimal";
+import { Duration } from "../google/protobuf/duration";
+import { Timestamp } from "../google/protobuf/timestamp";
+
+export const protobufPackage = "bytebase.store";
+
+/** SlowQueryStatistics is a summary of slow queries. */
+export interface SlowQueryStatistics {
+ /** sql_fingerprint is the fingerprint of the slow query. */
+ sqlFingerprint: string;
+ /** count is the number of slow queries with the same fingerprint. */
+ count: number;
+ /** latest_log_time is the time of the latest slow query with the same fingerprint. */
+ latestLogTime?: Date;
+ /** samples are the details of the sample slow queries with the same fingerprint. */
+ samples: SlowQueryDetails[];
+}
+
+/** SlowQueryDetails is the details of a slow query. */
+export interface SlowQueryDetails {
+ /** start_time is the start time of the slow query. */
+ startTime?: Date;
+ /** query_time is the query time of the slow query. */
+ queryTime?: Duration;
+ /** lock_time is the lock time of the slow query. */
+ lockTime?: Duration;
+ /** rows_sent is the number of rows sent by the slow query. */
+ rowsSent: number;
+ /** rows_examined is the number of rows examined by the slow query. */
+ rowsExamined: number;
+ /** sql_text is the SQL text of the slow query. */
+ sqlText: string;
+}
+
+function createBaseSlowQueryStatistics(): SlowQueryStatistics {
+ return { sqlFingerprint: "", count: 0, latestLogTime: undefined, samples: [] };
+}
+
+export const SlowQueryStatistics = {
+ encode(message: SlowQueryStatistics, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
+ if (message.sqlFingerprint !== "") {
+ writer.uint32(10).string(message.sqlFingerprint);
+ }
+ if (message.count !== 0) {
+ writer.uint32(16).int32(message.count);
+ }
+ if (message.latestLogTime !== undefined) {
+ Timestamp.encode(toTimestamp(message.latestLogTime), writer.uint32(26).fork()).ldelim();
+ }
+ for (const v of message.samples) {
+ SlowQueryDetails.encode(v!, writer.uint32(34).fork()).ldelim();
+ }
+ return writer;
+ },
+
+ decode(input: _m0.Reader | Uint8Array, length?: number): SlowQueryStatistics {
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
+ let end = length === undefined ? reader.len : reader.pos + length;
+ const message = createBaseSlowQueryStatistics();
+ while (reader.pos < end) {
+ const tag = reader.uint32();
+ switch (tag >>> 3) {
+ case 1:
+ if (tag != 10) {
+ break;
+ }
+
+ message.sqlFingerprint = reader.string();
+ continue;
+ case 2:
+ if (tag != 16) {
+ break;
+ }
+
+ message.count = reader.int32();
+ continue;
+ case 3:
+ if (tag != 26) {
+ break;
+ }
+
+ message.latestLogTime = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
+ continue;
+ case 4:
+ if (tag != 34) {
+ break;
+ }
+
+ message.samples.push(SlowQueryDetails.decode(reader, reader.uint32()));
+ continue;
+ }
+ if ((tag & 7) == 4 || tag == 0) {
+ break;
+ }
+ reader.skipType(tag & 7);
+ }
+ return message;
+ },
+
+ fromJSON(object: any): SlowQueryStatistics {
+ return {
+ sqlFingerprint: isSet(object.sqlFingerprint) ? String(object.sqlFingerprint) : "",
+ count: isSet(object.count) ? Number(object.count) : 0,
+ latestLogTime: isSet(object.latestLogTime) ? fromJsonTimestamp(object.latestLogTime) : undefined,
+ samples: Array.isArray(object?.samples) ? object.samples.map((e: any) => SlowQueryDetails.fromJSON(e)) : [],
+ };
+ },
+
+ toJSON(message: SlowQueryStatistics): unknown {
+ const obj: any = {};
+ message.sqlFingerprint !== undefined && (obj.sqlFingerprint = message.sqlFingerprint);
+ message.count !== undefined && (obj.count = Math.round(message.count));
+ message.latestLogTime !== undefined && (obj.latestLogTime = message.latestLogTime.toISOString());
+ if (message.samples) {
+ obj.samples = message.samples.map((e) => e ? SlowQueryDetails.toJSON(e) : undefined);
+ } else {
+ obj.samples = [];
+ }
+ return obj;
+ },
+
+ create(base?: DeepPartial<SlowQueryStatistics>): SlowQueryStatistics {
+ return SlowQueryStatistics.fromPartial(base ?? {});
+ },
+
+ fromPartial(object: DeepPartial<SlowQueryStatistics>): SlowQueryStatistics {
+ const message = createBaseSlowQueryStatistics();
+ message.sqlFingerprint = object.sqlFingerprint ?? "";
+ message.count = object.count ?? 0;
+ message.latestLogTime = object.latestLogTime ?? undefined;
+ message.samples = object.samples?.map((e) => SlowQueryDetails.fromPartial(e)) || [];
+ return message;
+ },
+};
+
+function createBaseSlowQueryDetails(): SlowQueryDetails {
+ return { startTime: undefined, queryTime: undefined, lockTime: undefined, rowsSent: 0, rowsExamined: 0, sqlText: "" };
+}
+
+export const SlowQueryDetails = {
+ encode(message: SlowQueryDetails, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
+ if (message.startTime !== undefined) {
+ Timestamp.encode(toTimestamp(message.startTime), writer.uint32(10).fork()).ldelim();
+ }
+ if (message.queryTime !== undefined) {
+ Duration.encode(message.queryTime, writer.uint32(18).fork()).ldelim();
+ }
+ if (message.lockTime !== undefined) {
+ Duration.encode(message.lockTime, writer.uint32(26).fork()).ldelim();
+ }
+ if (message.rowsSent !== 0) {
+ writer.uint32(32).int32(message.rowsSent);
+ }
+ if (message.rowsExamined !== 0) {
+ writer.uint32(40).int32(message.rowsExamined);
+ }
+ if (message.sqlText !== "") {
+ writer.uint32(50).string(message.sqlText);
+ }
+ return writer;
+ },
+
+ decode(input: _m0.Reader | Uint8Array, length?: number): SlowQueryDetails {
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
+ let end = length === undefined ? reader.len : reader.pos + length;
+ const message = createBaseSlowQueryDetails();
+ while (reader.pos < end) {
+ const tag = reader.uint32();
+ switch (tag >>> 3) {
+ case 1:
+ if (tag != 10) {
+ break;
+ }
+
+ message.startTime = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
+ continue;
+ case 2:
+ if (tag != 18) {
+ break;
+ }
+
+ message.queryTime = Duration.decode(reader, reader.uint32());
+ continue;
+ case 3:
+ if (tag != 26) {
+ break;
+ }
+
+ message.lockTime = Duration.decode(reader, reader.uint32());
+ continue;
+ case 4:
+ if (tag != 32) {
+ break;
+ }
+
+ message.rowsSent = reader.int32();
+ continue;
+ case 5:
+ if (tag != 40) {
+ break;
+ }
+
+ message.rowsExamined = reader.int32();
+ continue;
+ case 6:
+ if (tag != 50) {
+ break;
+ }
+
+ message.sqlText = reader.string();
+ continue;
+ }
+ if ((tag & 7) == 4 || tag == 0) {
+ break;
+ }
+ reader.skipType(tag & 7);
+ }
+ return message;
+ },
+
+ fromJSON(object: any): SlowQueryDetails {
+ return {
+ startTime: isSet(object.startTime) ? fromJsonTimestamp(object.startTime) : undefined,
+ queryTime: isSet(object.queryTime) ? Duration.fromJSON(object.queryTime) : undefined,
+ lockTime: isSet(object.lockTime) ? Duration.fromJSON(object.lockTime) : undefined,
+ rowsSent: isSet(object.rowsSent) ? Number(object.rowsSent) : 0,
+ rowsExamined: isSet(object.rowsExamined) ? Number(object.rowsExamined) : 0,
+ sqlText: isSet(object.sqlText) ? String(object.sqlText) : "",
+ };
+ },
+
+ toJSON(message: SlowQueryDetails): unknown {
+ const obj: any = {};
+ message.startTime !== undefined && (obj.startTime = message.startTime.toISOString());
+ message.queryTime !== undefined &&
+ (obj.queryTime = message.queryTime ? Duration.toJSON(message.queryTime) : undefined);
+ message.lockTime !== undefined && (obj.lockTime = message.lockTime ? Duration.toJSON(message.lockTime) : undefined);
+ message.rowsSent !== undefined && (obj.rowsSent = Math.round(message.rowsSent));
+ message.rowsExamined !== undefined && (obj.rowsExamined = Math.round(message.rowsExamined));
+ message.sqlText !== undefined && (obj.sqlText = message.sqlText);
+ return obj;
+ },
+
+ create(base?: DeepPartial<SlowQueryDetails>): SlowQueryDetails {
+ return SlowQueryDetails.fromPartial(base ?? {});
+ },
+
+ fromPartial(object: DeepPartial<SlowQueryDetails>): SlowQueryDetails {
+ const message = createBaseSlowQueryDetails();
+ message.startTime = object.startTime ?? undefined;
+ message.queryTime = (object.queryTime !== undefined && object.queryTime !== null)
+ ? Duration.fromPartial(object.queryTime)
+ : undefined;
+ message.lockTime = (object.lockTime !== undefined && object.lockTime !== null)
+ ? Duration.fromPartial(object.lockTime)
+ : undefined;
+ message.rowsSent = object.rowsSent ?? 0;
+ message.rowsExamined = object.rowsExamined ?? 0;
+ message.sqlText = object.sqlText ?? "";
+ return message;
+ },
+};
+
+type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
+
+export type DeepPartial<T> = T extends Builtin ? T
+ : T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
+ : T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
+ : Partial<T>;
+
+function toTimestamp(date: Date): Timestamp {
+ const seconds = date.getTime() / 1_000;
+ const nanos = (date.getTime() % 1_000) * 1_000_000;
+ return { seconds, nanos };
+}
+
+function fromTimestamp(t: Timestamp): Date {
+ let millis = t.seconds * 1_000;
+ millis += t.nanos / 1_000_000;
+ return new Date(millis);
+}
+
+function fromJsonTimestamp(o: any): Date {
+ if (o instanceof Date) {
+ return o;
+ } else if (typeof o === "string") {
+ return new Date(o);
+ } else {
+ return fromTimestamp(Timestamp.fromJSON(o));
+ }
+}
+
+function isSet(value: any): boolean {
+ return value !== null && value !== undefined;
+}
diff --git a/frontend/src/types/proto/v1/database_service.ts b/frontend/src/types/proto/v1/database_service.ts
index e53f8a3574..7d5bd73ac5 100644
--- a/frontend/src/types/proto/v1/database_service.ts
+++ b/frontend/src/types/proto/v1/database_service.ts
@@ -569,8 +569,8 @@ export interface SlowQueryStatistics {
averageRowsExamined: number;
/** The nighty fifth percentile rows examined of the slow query log. */
nightyFifthPercentileRowsExamined: number;
- /** The details of the slow query log. */
- details: SlowQueryDetails[];
+ /** Samples are details of the sample slow query logs with the same fingerprint. */
+ samples: SlowQueryDetails[];
}
/** SlowQueryDetails is the details of the slow query log. */
@@ -3415,7 +3415,7 @@ function createBaseSlowQueryStatistics(): SlowQueryStatistics {
nightyFifthPercentileRowsSent: 0,
averageRowsExamined: 0,
nightyFifthPercentileRowsExamined: 0,
- details: [],
+ samples: [],
};
}
@@ -3448,7 +3448,7 @@ export const SlowQueryStatistics = {
if (message.nightyFifthPercentileRowsExamined !== 0) {
writer.uint32(72).int32(message.nightyFifthPercentileRowsExamined);
}
- for (const v of message.details) {
+ for (const v of message.samples) {
SlowQueryDetails.encode(v!, writer.uint32(82).fork()).ldelim();
}
return writer;
@@ -3529,7 +3529,7 @@ export const SlowQueryStatistics = {
break;
}
- message.details.push(SlowQueryDetails.decode(reader, reader.uint32()));
+ message.samples.push(SlowQueryDetails.decode(reader, reader.uint32()));
continue;
}
if ((tag & 7) == 4 || tag == 0) {
@@ -3557,7 +3557,7 @@ export const SlowQueryStatistics = {
nightyFifthPercentileRowsExamined: isSet(object.nightyFifthPercentileRowsExamined)
? Number(object.nightyFifthPercentileRowsExamined)
: 0,
- details: Array.isArray(object?.details) ? object.details.map((e: any) => SlowQueryDetails.fromJSON(e)) : [],
+ samples: Array.isArray(object?.samples) ? object.samples.map((e: any) => SlowQueryDetails.fromJSON(e)) : [],
};
},
@@ -3578,10 +3578,10 @@ export const SlowQueryStatistics = {
message.averageRowsExamined !== undefined && (obj.averageRowsExamined = Math.round(message.averageRowsExamined));
message.nightyFifthPercentileRowsExamined !== undefined &&
(obj.nightyFifthPercentileRowsExamined = Math.round(message.nightyFifthPercentileRowsExamined));
- if (message.details) {
- obj.details = message.details.map((e) => e ? SlowQueryDetails.toJSON(e) : undefined);
+ if (message.samples) {
+ obj.samples = message.samples.map((e) => e ? SlowQueryDetails.toJSON(e) : undefined);
} else {
- obj.details = [];
+ obj.samples = [];
}
return obj;
},
@@ -3606,7 +3606,7 @@ export const SlowQueryStatistics = {
message.nightyFifthPercentileRowsSent = object.nightyFifthPercentileRowsSent ?? 0;
message.averageRowsExamined = object.averageRowsExamined ?? 0;
message.nightyFifthPercentileRowsExamined = object.nightyFifthPercentileRowsExamined ?? 0;
- message.details = object.details?.map((e) => SlowQueryDetails.fromPartial(e)) || [];
+ message.samples = object.samples?.map((e) => SlowQueryDetails.fromPartial(e)) || [];
return message;
},
};
diff --git a/proto/gen/grpc-doc/store/README.md b/proto/gen/grpc-doc/store/README.md
index 1055db6eb6..9b23a12382 100644
--- a/proto/gen/grpc-doc/store/README.md
+++ b/proto/gen/grpc-doc/store/README.md
@@ -61,6 +61,10 @@
- [WorkspaceApprovalSetting.Rule](#bytebase-store-WorkspaceApprovalSetting-Rule)
- [WorkspaceProfileSetting](#bytebase-store-WorkspaceProfileSetting)
+- [store/slow_query.proto](#store_slow_query-proto)
+ - [SlowQueryDetails](#bytebase-store-SlowQueryDetails)
+ - [SlowQueryStatistics](#bytebase-store-SlowQueryStatistics)
+
- [store/user.proto](#store_user-proto)
- [MFAConfig](#bytebase-store-MFAConfig)
@@ -889,6 +893,60 @@ The external URL is used for: 1. Constructing the correct callback URL when conf
+<a name="store_slow_query-proto"></a>
+<p align="right"><a href="#top">Top</a></p>
+
+## store/slow_query.proto
+
+
+
+<a name="bytebase-store-SlowQueryDetails"></a>
+
+### SlowQueryDetails
+SlowQueryDetails is the details of a slow query.
+
+
+| Field | Type | Label | Description |
+| ----- | ---- | ----- | ----------- |
+| 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. |
+| sql_text | [string](#string) | | sql_text is the SQL text of the slow query. |
+
+
+
+
+
+
+<a name="bytebase-store-SlowQueryStatistics"></a>
+
+### SlowQueryStatistics
+SlowQueryStatistics is a summary of slow queries.
+
+
+| 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. |
+| latest_log_time | [google.protobuf.Timestamp](#google-protobuf-Timestamp) | | latest_log_time is the time of the latest slow query with the same fingerprint. |
+| samples | [SlowQueryDetails](#bytebase-store-SlowQueryDetails) | repeated | samples are the details of the sample slow queries with the same fingerprint. |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
<a name="store_user-proto"></a>
<p align="right"><a href="#top">Top</a></p>
diff --git a/proto/gen/grpc-doc/v1/README.md b/proto/gen/grpc-doc/v1/README.md
index aa163202a7..f743afcdbd 100644
--- a/proto/gen/grpc-doc/v1/README.md
+++ b/proto/gen/grpc-doc/v1/README.md
@@ -1563,7 +1563,7 @@ SlowQueryStatistics is the statistics of the slow query log.
| nighty_fifth_percentile_rows_sent | [int32](#int32) | | The nighty fifth percentile rows sent of the slow query log. |
| average_rows_examined | [int32](#int32) | | The average rows examined of the slow query log. |
| nighty_fifth_percentile_rows_examined | [int32](#int32) | | The nighty fifth percentile rows examined of the slow query log. |
-| details | [SlowQueryDetails](#bytebase-v1-SlowQueryDetails) | repeated | The details 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.go
new file mode 100644
index 0000000000..0f389e7672
--- /dev/null
+++ b/proto/generated-go/store/slow_query.pb.go
@@ -0,0 +1,321 @@
+// Code generated by protoc-gen-go. DO NOT EDIT.
+// versions:
+// protoc-gen-go v1.29.0
+// protoc (unknown)
+// source: store/slow_query.proto
+
+package store
+
+import (
+ protoreflect "google.golang.org/protobuf/reflect/protoreflect"
+ protoimpl "google.golang.org/protobuf/runtime/protoimpl"
+ durationpb "google.golang.org/protobuf/types/known/durationpb"
+ timestamppb "google.golang.org/protobuf/types/known/timestamppb"
+ reflect "reflect"
+ sync "sync"
+)
+
+const (
+ // Verify that this generated code is sufficiently up-to-date.
+ _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
+ // Verify that runtime/protoimpl is sufficiently up-to-date.
+ _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
+)
+
+// SlowQueryStatistics is a summary of slow queries.
+type SlowQueryStatistics struct {
+ state protoimpl.MessageState
+ sizeCache protoimpl.SizeCache
+ unknownFields protoimpl.UnknownFields
+
+ // 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"`
+ // 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"`
+ // samples are the details of the sample slow queries with the same fingerprint.
+ Samples []*SlowQueryDetails `protobuf:"bytes,4,rep,name=samples,proto3" json:"samples,omitempty"`
+}
+
+func (x *SlowQueryStatistics) Reset() {
+ *x = SlowQueryStatistics{}
+ if protoimpl.UnsafeEnabled {
+ mi := &file_store_slow_query_proto_msgTypes[0]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+ }
+}
+
+func (x *SlowQueryStatistics) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*SlowQueryStatistics) ProtoMessage() {}
+
+func (x *SlowQueryStatistics) ProtoReflect() protoreflect.Message {
+ mi := &file_store_slow_query_proto_msgTypes[0]
+ if protoimpl.UnsafeEnabled && x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use SlowQueryStatistics.ProtoReflect.Descriptor instead.
+func (*SlowQueryStatistics) Descriptor() ([]byte, []int) {
+ return file_store_slow_query_proto_rawDescGZIP(), []int{0}
+}
+
+func (x *SlowQueryStatistics) GetSqlFingerprint() string {
+ if x != nil {
+ return x.SqlFingerprint
+ }
+ return ""
+}
+
+func (x *SlowQueryStatistics) GetCount() int32 {
+ if x != nil {
+ return x.Count
+ }
+ return 0
+}
+
+func (x *SlowQueryStatistics) GetLatestLogTime() *timestamppb.Timestamp {
+ if x != nil {
+ return x.LatestLogTime
+ }
+ return nil
+}
+
+func (x *SlowQueryStatistics) GetSamples() []*SlowQueryDetails {
+ if x != nil {
+ return x.Samples
+ }
+ return nil
+}
+
+// SlowQueryDetails is the details of a slow query.
+type SlowQueryDetails struct {
+ state protoimpl.MessageState
+ sizeCache protoimpl.SizeCache
+ unknownFields protoimpl.UnknownFields
+
+ // start_time is the start time of the slow query.
+ StartTime *timestamppb.Timestamp `protobuf:"bytes,1,opt,name=start_time,json=startTime,proto3" json:"start_time,omitempty"`
+ // query_time is the query time of the slow query.
+ QueryTime *durationpb.Duration `protobuf:"bytes,2,opt,name=query_time,json=queryTime,proto3" json:"query_time,omitempty"`
+ // 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"`
+ // 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"`
+ // 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"`
+}
+
+func (x *SlowQueryDetails) Reset() {
+ *x = SlowQueryDetails{}
+ if protoimpl.UnsafeEnabled {
+ mi := &file_store_slow_query_proto_msgTypes[1]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+ }
+}
+
+func (x *SlowQueryDetails) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*SlowQueryDetails) ProtoMessage() {}
+
+func (x *SlowQueryDetails) ProtoReflect() protoreflect.Message {
+ mi := &file_store_slow_query_proto_msgTypes[1]
+ if protoimpl.UnsafeEnabled && x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use SlowQueryDetails.ProtoReflect.Descriptor instead.
+func (*SlowQueryDetails) Descriptor() ([]byte, []int) {
+ return file_store_slow_query_proto_rawDescGZIP(), []int{1}
+}
+
+func (x *SlowQueryDetails) GetStartTime() *timestamppb.Timestamp {
+ if x != nil {
+ return x.StartTime
+ }
+ return nil
+}
+
+func (x *SlowQueryDetails) GetQueryTime() *durationpb.Duration {
+ if x != nil {
+ return x.QueryTime
+ }
+ return nil
+}
+
+func (x *SlowQueryDetails) GetLockTime() *durationpb.Duration {
+ if x != nil {
+ return x.LockTime
+ }
+ return nil
+}
+
+func (x *SlowQueryDetails) GetRowsSent() int32 {
+ if x != nil {
+ return x.RowsSent
+ }
+ return 0
+}
+
+func (x *SlowQueryDetails) GetRowsExamined() int32 {
+ if x != nil {
+ return x.RowsExamined
+ }
+ return 0
+}
+
+func (x *SlowQueryDetails) GetSqlText() string {
+ if x != nil {
+ return x.SqlText
+ }
+ return ""
+}
+
+var File_store_slow_query_proto protoreflect.FileDescriptor
+
+var file_store_slow_query_proto_rawDesc = []byte{
+ 0x0a, 0x16, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2f, 0x73, 0x6c, 0x6f, 0x77, 0x5f, 0x71, 0x75, 0x65,
+ 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61,
+ 0x73, 0x65, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65,
+ 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74,
+ 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x67, 0x6f, 0x6f, 0x67, 0x6c,
+ 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x75, 0x72, 0x61, 0x74,
+ 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xd4, 0x01, 0x0a, 0x13, 0x53, 0x6c,
+ 0x6f, 0x77, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, 0x74, 0x61, 0x74, 0x69, 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, 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, 0x0d, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x4c, 0x6f, 0x67,
+ 0x54, 0x69, 0x6d, 0x65, 0x12, 0x3a, 0x0a, 0x07, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x18,
+ 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65,
+ 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x53, 0x6c, 0x6f, 0x77, 0x51, 0x75, 0x65, 0x72, 0x79,
+ 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x52, 0x07, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73,
+ 0x22, 0x9c, 0x02, 0x0a, 0x10, 0x53, 0x6c, 0x6f, 0x77, 0x51, 0x75, 0x65, 0x72, 0x79, 0x44, 0x65,
+ 0x74, 0x61, 0x69, 0x6c, 0x73, 0x12, 0x39, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x74,
+ 0x69, 0x6d, 0x65, 0x18, 0x01, 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, 0x09, 0x73, 0x74, 0x61, 0x72, 0x74, 0x54, 0x69, 0x6d, 0x65,
+ 0x12, 0x38, 0x0a, 0x0a, 0x71, 0x75, 0x65, 0x72, 0x79, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02,
+ 0x20, 0x01, 0x28, 0x0b, 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,
+ 0x09, 0x71, 0x75, 0x65, 0x72, 0x79, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x36, 0x0a, 0x09, 0x6c, 0x6f,
+ 0x63, 0x6b, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 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, 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,
+ 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,
+ 0x73, 0x74, 0x6f, 0x72, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+}
+
+var (
+ file_store_slow_query_proto_rawDescOnce sync.Once
+ file_store_slow_query_proto_rawDescData = file_store_slow_query_proto_rawDesc
+)
+
+func file_store_slow_query_proto_rawDescGZIP() []byte {
+ file_store_slow_query_proto_rawDescOnce.Do(func() {
+ file_store_slow_query_proto_rawDescData = protoimpl.X.CompressGZIP(file_store_slow_query_proto_rawDescData)
+ })
+ return file_store_slow_query_proto_rawDescData
+}
+
+var file_store_slow_query_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
+var file_store_slow_query_proto_goTypes = []interface{}{
+ (*SlowQueryStatistics)(nil), // 0: bytebase.store.SlowQueryStatistics
+ (*SlowQueryDetails)(nil), // 1: bytebase.store.SlowQueryDetails
+ (*timestamppb.Timestamp)(nil), // 2: google.protobuf.Timestamp
+ (*durationpb.Duration)(nil), // 3: google.protobuf.Duration
+}
+var file_store_slow_query_proto_depIdxs = []int32{
+ 2, // 0: bytebase.store.SlowQueryStatistics.latest_log_time:type_name -> google.protobuf.Timestamp
+ 1, // 1: bytebase.store.SlowQueryStatistics.samples:type_name -> bytebase.store.SlowQueryDetails
+ 2, // 2: bytebase.store.SlowQueryDetails.start_time:type_name -> google.protobuf.Timestamp
+ 3, // 3: bytebase.store.SlowQueryDetails.query_time:type_name -> google.protobuf.Duration
+ 3, // 4: bytebase.store.SlowQueryDetails.lock_time:type_name -> google.protobuf.Duration
+ 5, // [5:5] is the sub-list for method output_type
+ 5, // [5:5] is the sub-list for method input_type
+ 5, // [5:5] is the sub-list for extension type_name
+ 5, // [5:5] is the sub-list for extension extendee
+ 0, // [0:5] is the sub-list for field type_name
+}
+
+func init() { file_store_slow_query_proto_init() }
+func file_store_slow_query_proto_init() {
+ if File_store_slow_query_proto != nil {
+ return
+ }
+ if !protoimpl.UnsafeEnabled {
+ file_store_slow_query_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
+ switch v := v.(*SlowQueryStatistics); i {
+ case 0:
+ return &v.state
+ case 1:
+ return &v.sizeCache
+ case 2:
+ return &v.unknownFields
+ default:
+ return nil
+ }
+ }
+ file_store_slow_query_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
+ switch v := v.(*SlowQueryDetails); i {
+ case 0:
+ return &v.state
+ case 1:
+ return &v.sizeCache
+ case 2:
+ return &v.unknownFields
+ default:
+ return nil
+ }
+ }
+ }
+ type x struct{}
+ out := protoimpl.TypeBuilder{
+ File: protoimpl.DescBuilder{
+ GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
+ RawDescriptor: file_store_slow_query_proto_rawDesc,
+ NumEnums: 0,
+ NumMessages: 2,
+ NumExtensions: 0,
+ NumServices: 0,
+ },
+ GoTypes: file_store_slow_query_proto_goTypes,
+ DependencyIndexes: file_store_slow_query_proto_depIdxs,
+ MessageInfos: file_store_slow_query_proto_msgTypes,
+ }.Build()
+ File_store_slow_query_proto = out.File
+ file_store_slow_query_proto_rawDesc = nil
+ file_store_slow_query_proto_goTypes = nil
+ file_store_slow_query_proto_depIdxs = nil
+}
diff --git a/proto/generated-go/v1/database_service.pb.go b/proto/generated-go/v1/database_service.pb.go
index cc46dda859..d019dc79b4 100644
--- a/proto/generated-go/v1/database_service.pb.go
+++ b/proto/generated-go/v1/database_service.pb.go
@@ -2287,8 +2287,8 @@ type SlowQueryStatistics struct {
AverageRowsExamined int32 `protobuf:"varint,8,opt,name=average_rows_examined,json=averageRowsExamined,proto3" json:"average_rows_examined,omitempty"`
// The nighty fifth percentile rows examined of the slow query log.
NightyFifthPercentileRowsExamined int32 `protobuf:"varint,9,opt,name=nighty_fifth_percentile_rows_examined,json=nightyFifthPercentileRowsExamined,proto3" json:"nighty_fifth_percentile_rows_examined,omitempty"`
- // The details of the slow query log.
- Details []*SlowQueryDetails `protobuf:"bytes,10,rep,name=details,proto3" json:"details,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"`
}
func (x *SlowQueryStatistics) Reset() {
@@ -2386,9 +2386,9 @@ func (x *SlowQueryStatistics) GetNightyFifthPercentileRowsExamined() int32 {
return 0
}
-func (x *SlowQueryStatistics) GetDetails() []*SlowQueryDetails {
+func (x *SlowQueryStatistics) GetSamples() []*SlowQueryDetails {
if x != nil {
- return x.Details
+ return x.Samples
}
return nil
}
@@ -2832,10 +2832,10 @@ var file_v1_database_service_proto_rawDesc = []byte{
0x5f, 0x65, 0x78, 0x61, 0x6d, 0x69, 0x6e, 0x65, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x05, 0x52,
0x21, 0x6e, 0x69, 0x67, 0x68, 0x74, 0x79, 0x46, 0x69, 0x66, 0x74, 0x68, 0x50, 0x65, 0x72, 0x63,
0x65, 0x6e, 0x74, 0x69, 0x6c, 0x65, 0x52, 0x6f, 0x77, 0x73, 0x45, 0x78, 0x61, 0x6d, 0x69, 0x6e,
- 0x65, 0x64, 0x12, 0x37, 0x0a, 0x07, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x18, 0x0a, 0x20,
+ 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, 0x65, 0x72, 0x79, 0x44, 0x65, 0x74, 0x61, 0x69,
- 0x6c, 0x73, 0x52, 0x07, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x22, 0x9c, 0x02, 0x0a, 0x10,
+ 0x6c, 0x73, 0x52, 0x07, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x22, 0x9c, 0x02, 0x0a, 0x10,
0x53, 0x6c, 0x6f, 0x77, 0x51, 0x75, 0x65, 0x72, 0x79, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73,
0x12, 0x39, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x01,
0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72,
@@ -3056,7 +3056,7 @@ var file_v1_database_service_proto_depIdxs = []int32{
36, // 27: bytebase.v1.SlowQueryStatistics.latest_log_time:type_name -> google.protobuf.Timestamp
38, // 28: bytebase.v1.SlowQueryStatistics.average_query_time:type_name -> google.protobuf.Duration
38, // 29: bytebase.v1.SlowQueryStatistics.nighty_fifth_percentile_query_time:type_name -> google.protobuf.Duration
- 32, // 30: bytebase.v1.SlowQueryStatistics.details:type_name -> bytebase.v1.SlowQueryDetails
+ 32, // 30: bytebase.v1.SlowQueryStatistics.samples:type_name -> bytebase.v1.SlowQueryDetails
36, // 31: bytebase.v1.SlowQueryDetails.start_time:type_name -> google.protobuf.Timestamp
38, // 32: bytebase.v1.SlowQueryDetails.query_time:type_name -> google.protobuf.Duration
38, // 33: bytebase.v1.SlowQueryDetails.lock_time:type_name -> google.protobuf.Duration
diff --git a/proto/store/slow_query.proto b/proto/store/slow_query.proto
new file mode 100644
index 0000000000..122de5a560
--- /dev/null
+++ b/proto/store/slow_query.proto
@@ -0,0 +1,44 @@
+syntax = "proto3";
+
+package bytebase.store;
+
+import "google/protobuf/timestamp.proto";
+import "google/protobuf/duration.proto";
+
+option go_package = "generated-go/store";
+
+// SlowQueryStatistics is a summary of slow queries.
+message SlowQueryStatistics {
+ // sql_fingerprint is the fingerprint of the slow query.
+ string sql_fingerprint = 1;
+
+ // count is the number of slow queries with the same fingerprint.
+ int32 count = 2;
+
+ // latest_log_time is the time of the latest slow query with the same fingerprint.
+ google.protobuf.Timestamp latest_log_time = 3;
+
+ // samples are the details of the sample slow queries with the same fingerprint.
+ repeated SlowQueryDetails samples = 4;
+}
+
+// SlowQueryDetails is the details of a slow query.
+message SlowQueryDetails {
+ // start_time is the start time of the slow query.
+ google.protobuf.Timestamp start_time = 1;
+
+ // query_time is the query time of the slow query.
+ google.protobuf.Duration query_time = 2;
+
+ // lock_time is the lock time of the slow query.
+ google.protobuf.Duration lock_time = 3;
+
+ // rows_sent is the number of rows sent by the slow query.
+ int32 rows_sent = 4;
+
+ // rows_examined is the number of rows examined by the slow query.
+ int32 rows_examined = 5;
+
+ // sql_text is the SQL text of the slow query.
+ string sql_text = 6;
+}
\ No newline at end of file
diff --git a/proto/v1/database_service.proto b/proto/v1/database_service.proto
index 4c382da7ea..3442b38b8a 100644
--- a/proto/v1/database_service.proto
+++ b/proto/v1/database_service.proto
@@ -577,8 +577,8 @@ message SlowQueryStatistics {
// The nighty fifth percentile rows examined of the slow query log.
int32 nighty_fifth_percentile_rows_examined = 9;
- // The details of the slow query log.
- repeated SlowQueryDetails details = 10;
+ // Samples are details of the sample slow query logs with the same fingerprint.
+ repeated SlowQueryDetails samples = 10;
}
// SlowQueryDetails is the details of the slow query log.