diff --git a/pkg/apiserver/slowquery/queries.go b/pkg/apiserver/slowquery/queries.go index a964c4a688..d99fb738d3 100644 --- a/pkg/apiserver/slowquery/queries.go +++ b/pkg/apiserver/slowquery/queries.go @@ -111,10 +111,18 @@ func QuerySlowLogList(req *GetListRequest, sysSchema *utils.SysSchema, db *gorm. return results, nil } -func QuerySlowLogDetail(req *GetDetailRequest, db *gorm.DB) (*Model, error) { +func QuerySlowLogDetail(req *GetDetailRequest, sysSchema *utils.SysSchema, db *gorm.DB) (*Model, error) { var result Model - err := db. - Select("*, (UNIX_TIMESTAMP(Time) + 0E0) AS timestamp"). + slowQueryColumns, err := sysSchema.GetTableColumnNames(db, SlowQueryTable) + if err != nil { + return nil, err + } + selectStmt, err := genSelectStmt(slowQueryColumns, []string{"*"}) + if err != nil { + return nil, err + } + err = db. + Select(selectStmt). Where("Digest = ?", req.Digest). Where("Time = FROM_UNIXTIME(?)", req.Timestamp). Where("Conn_id = ?", req.ConnectID). diff --git a/pkg/apiserver/slowquery/service.go b/pkg/apiserver/slowquery/service.go index 08ff2c0443..0a12411b1a 100644 --- a/pkg/apiserver/slowquery/service.go +++ b/pkg/apiserver/slowquery/service.go @@ -94,7 +94,7 @@ func (s *Service) getDetails(c *gin.Context) { } db := utils.GetTiDBConnection(c) - result, err := QuerySlowLogDetail(&req, db.Table(SlowQueryTable)) + result, err := QuerySlowLogDetail(&req, s.params.SysSchema, db.Table(SlowQueryTable)) if err != nil { rest.Error(c, err) return diff --git a/tests/integration/slowquery/mock_db_test.go b/tests/integration/slowquery/mock_db_test.go index 33aec0f8dc..85117809d3 100644 --- a/tests/integration/slowquery/mock_db_test.go +++ b/tests/integration/slowquery/mock_db_test.go @@ -52,7 +52,7 @@ func (s *testMockDBSuite) mustQuerySlowLogList(req *slowquery.GetListRequest) [] } func (s *testMockDBSuite) mustQuerySlowLogDetail(req *slowquery.GetDetailRequest) (*slowquery.Model, error) { - d, err := slowquery.QuerySlowLogDetail(req, s.mockDBSession()) + d, err := slowquery.QuerySlowLogDetail(req, s.sysSchema, s.mockDBSession()) return d, err } diff --git a/ui/packages/tidb-dashboard-lib/src/apps/SlowQuery/translations/en.yaml b/ui/packages/tidb-dashboard-lib/src/apps/SlowQuery/translations/en.yaml index 2c3bee81ac..d8140a3901 100644 --- a/ui/packages/tidb-dashboard-lib/src/apps/SlowQuery/translations/en.yaml +++ b/ui/packages/tidb-dashboard-lib/src/apps/SlowQuery/translations/en.yaml @@ -122,8 +122,8 @@ slow_query: ru_tooltip: request units resource_group: Resource Group resource_group_tooltip: The resource group that the query belongs to - time_queued_by_rc: Time Queued by RC - time_queued_by_rc_tooltip: The wait time spent in the resource queue + time_queued_by_rc: The total time queued by RC + time_queued_by_rc_tooltip: 'The total wait time spent in the resource queue (note: {{distro.tikv}} executes requests in parallel so that t this is not a wall time)' common: status: diff --git a/ui/packages/tidb-dashboard-lib/src/apps/SlowQuery/translations/zh.yaml b/ui/packages/tidb-dashboard-lib/src/apps/SlowQuery/translations/zh.yaml index e6b05cdca0..1ce0e4b8a3 100644 --- a/ui/packages/tidb-dashboard-lib/src/apps/SlowQuery/translations/zh.yaml +++ b/ui/packages/tidb-dashboard-lib/src/apps/SlowQuery/translations/zh.yaml @@ -124,8 +124,8 @@ slow_query: ru_tooltip: 资源单位(RU) resource_group: 资源组 resource_group_tooltip: SQL 语句所属的资源组 - time_queued_by_rc: RC 等待耗时 - time_queued_by_rc_tooltip: SQL 语句在资源组队列中等待的时间 + time_queued_by_rc: RC 等待累积耗时 + time_queued_by_rc_tooltip: SQL 语句在资源组队列中等待的累积时间(注:{{distro.tikv}} 会并行等待任务,因此该时间不是自然流逝时间) common: status: diff --git a/ui/packages/tidb-dashboard-lib/src/apps/Statement/translations/en.yaml b/ui/packages/tidb-dashboard-lib/src/apps/Statement/translations/en.yaml index d6fbb353bc..ab2a17fac4 100755 --- a/ui/packages/tidb-dashboard-lib/src/apps/Statement/translations/en.yaml +++ b/ui/packages/tidb-dashboard-lib/src/apps/Statement/translations/en.yaml @@ -198,7 +198,7 @@ statement: sum_ru: Total RU sum_ru_tooltip: The total number of request units (RU) consumed by the statement avg_time_queued_by_rc: Mean RC Wait Time in Queue - avg_time_queued_by_rc_tooltip: The average time that the query waits in the resource control's queue + avg_time_queued_by_rc_tooltip: The average time that the query waits in the resource control's queue (not a wall time) max_time_queued_by_rc: Max RC Wait Time in Queue - max_time_queued_by_rc_tooltip: The maximum time that the query waits in the resource control's queue - rc_wait_time: Wait Time in Resource Control + max_time_queued_by_rc_tooltip: The maximum time that the query waits in the resource control's queue (not a wall time) + rc_wait_time_tooltip: 'The total wait time spent in the resource queue (note: {{distro.tikv}} executes requests in parallel so that t this is not a wall time)' diff --git a/ui/packages/tidb-dashboard-lib/src/apps/Statement/translations/zh.yaml b/ui/packages/tidb-dashboard-lib/src/apps/Statement/translations/zh.yaml index 2a46291a01..4f4f52da3d 100755 --- a/ui/packages/tidb-dashboard-lib/src/apps/Statement/translations/zh.yaml +++ b/ui/packages/tidb-dashboard-lib/src/apps/Statement/translations/zh.yaml @@ -205,7 +205,8 @@ statement: sum_ru: 累积 RU sum_ru_tooltip: 该 Statement 的 RU 累积值 avg_time_queued_by_rc: RC 平均等待耗时 - avg_time_queued_by_rc_tooltip: SQL 语句在资源组控制队列中平均等待的时间 (Resource Control) + avg_time_queued_by_rc_tooltip: SQL 语句在资源组控制队列中平均等待的时间 (Resource Control)(注:{{distro.tikv}} 会并行处理任务,因此该时间不是自然流逝时间) max_time_queued_by_rc: RC 最大等待耗时 - max_time_queued_by_rc_tooltip: SQL 语句在资源组控制队列中最大等待的时间 (Resource Control) - rc_wait_time: RC 资源控制等待耗时 + max_time_queued_by_rc_tooltip: SQL 语句在资源组控制队列中最大等待的时间 (Resource Control)(注:{{distro.tikv}} 会并行处理任务,因此该时间不是自然流逝时间) + rc_wait_time: RC 资源控制等待累积耗时 + rc_wait_time_tooltip: SQL 语句在资源组队列中等待的累积时间(注:{{distro.tikv}} 会并行等待任务,因此该时间不是自然流逝时间)