diff --git a/pkg/apiserver/statement/models.go b/pkg/apiserver/statement/models.go
index 40d4030d22..a32e32ada8 100644
--- a/pkg/apiserver/statement/models.go
+++ b/pkg/apiserver/statement/models.go
@@ -34,6 +34,7 @@ type TimeRange struct {
}
type Model struct {
+ AggPlanCount int `json:"plan_count" agg:"COUNT(DISTINCT plan_digest)"`
AggExecCount int `json:"exec_count" agg:"SUM(exec_count)"`
AggSumErrors int `json:"sum_errors" agg:"SUM(sum_errors)"`
AggSumWarnings int `json:"sum_warnings" agg:"SUM(sum_warnings)"`
diff --git a/pkg/apiserver/statement/queries.go b/pkg/apiserver/statement/queries.go
index 6ae5edef7c..d2b4e24bd4 100644
--- a/pkg/apiserver/statement/queries.go
+++ b/pkg/apiserver/statement/queries.go
@@ -134,6 +134,7 @@ func QueryStatementsOverview(
schemas, stmtTypes []string,
text string) (result []Model, err error) {
fields := getAggrFields(
+ "plan_count",
"table_names",
"schema_name",
"digest",
@@ -158,7 +159,7 @@ func QueryStatementsOverview(
Select(strings.Join(fields, ", ")).
Table(statementsTable).
Where("summary_begin_time >= FROM_UNIXTIME(?) AND summary_end_time <= FROM_UNIXTIME(?)", beginTime, endTime).
- Group("schema_name, digest, digest_text").
+ Group("schema_name, digest").
Order("agg_sum_latency DESC")
if len(schemas) > 0 {
diff --git a/ui/lib/apps/Statement/pages/Detail/index.tsx b/ui/lib/apps/Statement/pages/Detail/index.tsx
index d94f413138..6a9ffc1621 100644
--- a/ui/lib/apps/Statement/pages/Detail/index.tsx
+++ b/ui/lib/apps/Statement/pages/Detail/index.tsx
@@ -132,7 +132,7 @@ function DetailPage() {
+
}
>
{plans.length}
diff --git a/ui/lib/apps/Statement/pages/List/index.tsx b/ui/lib/apps/Statement/pages/List/index.tsx
index 8ee06e2573..7d8d54e50f 100644
--- a/ui/lib/apps/Statement/pages/List/index.tsx
+++ b/ui/lib/apps/Statement/pages/List/index.tsx
@@ -31,7 +31,7 @@ const defColumnKeys: IColumnKeys = {
sum_latency: true,
avg_latency: true,
exec_count: true,
- avg_mem: true,
+ plan_count: true,
related_schemas: true,
}
diff --git a/ui/lib/apps/Statement/translations/en.yaml b/ui/lib/apps/Statement/translations/en.yaml
index 529b00e9d2..837e8c4481 100644
--- a/ui/lib/apps/Statement/translations/en.yaml
+++ b/ui/lib/apps/Statement/translations/en.yaml
@@ -7,7 +7,6 @@ statement:
title: Statement Information
desc:
time_range: Selected Time Range
- plan_count: Execution Plans
plans:
note: There are multiple execution plans for this kind of SQL statement. You can choose to view one or multiple of them.
title:
@@ -65,8 +64,10 @@ statement:
digest_text_tooltip: Similar queries have same statement template even for different query parameters
sum_latency: Total Latency
sum_latency_tooltip: Total execution time for this kind of statement
- exec_count: Execution Count
+ exec_count: '# Exec'
exec_count_tooltip: Total execution count for this kind of statement
+ plan_count: '# Plans'
+ plan_count_tooltip: Number of distinct execution plans of this statement in current time range
avg_latency: Mean Latency
avg_latency_tooltip: Execution time of single query
avg_mem: Mean Memory
diff --git a/ui/lib/apps/Statement/translations/zh.yaml b/ui/lib/apps/Statement/translations/zh.yaml
index 670bf52513..6455567230 100644
--- a/ui/lib/apps/Statement/translations/zh.yaml
+++ b/ui/lib/apps/Statement/translations/zh.yaml
@@ -7,7 +7,6 @@ statement:
title: SQL 语句信息
desc:
time_range: 时间范围
- plan_count: 执行计划数
plans:
note: 该 SQL 模板在选定的时间范围内有多个执行计划,您可以选择查看其中一个或多个执行计划。
title:
@@ -66,6 +65,8 @@ statement:
sum_latency_tooltip: 该类 SQL 语句在时间段内的累计执行时间
exec_count: 执行次数
exec_count_tooltip: 该类 SQL 语句在时间段内被执行的总次数
+ plan_count: 计划数
+ plan_count_tooltip: 该类 SQL 语句在时间段内的不同执行计划数量
avg_latency: 平均耗时
avg_latency_tooltip: 单条 SQL 查询的执行时间
avg_mem: 平均内存
diff --git a/ui/lib/apps/Statement/utils/tableColumns.tsx b/ui/lib/apps/Statement/utils/tableColumns.tsx
index b6d91b8a04..a249e8610b 100644
--- a/ui/lib/apps/Statement/utils/tableColumns.tsx
+++ b/ui/lib/apps/Statement/utils/tableColumns.tsx
@@ -15,6 +15,19 @@ function commonColumnName(fieldName: string): any {
return
}
+function planCountColumn(
+ _rows?: { plan_count?: number }[] // used for type check only
+): IColumn {
+ return {
+ name: commonColumnName('plan_count'),
+ key: 'plan_count',
+ fieldName: 'plan_count',
+ minWidth: 100,
+ maxWidth: 300,
+ columnActionsMode: ColumnActionsMode.clickable,
+ }
+}
+
function planDigestColumn(
_rows?: { plan_digest?: string }[] // used for type check only
): IColumn {
@@ -322,6 +335,7 @@ export function statementColumns(
sumLatencyColumn(rows),
avgMinMaxLatencyColumn(rows),
execCountColumn(rows),
+ planCountColumn(rows),
avgMaxMemColumn(rows),
errorsWarningsColumn(rows),
avgParseLatencyColumn(rows),