From 78ff2065c16ec8f05c0e0caef9a52d11fe4b180b Mon Sep 17 00:00:00 2001 From: crazycs Date: Thu, 26 Nov 2020 17:22:32 +0800 Subject: [PATCH] ui: add more time field for slow query detail page (#810) Signed-off-by: crazycs520 --- pkg/apiserver/slowquery/queries.go | 47 ++++++++------ .../SlowQuery/pages/Detail/DetailTabTime.tsx | 62 +++++++++++++++---- ui/lib/apps/SlowQuery/translations/en.yaml | 53 +++++++++++----- ui/lib/apps/SlowQuery/translations/zh.yaml | 56 ++++++++++++----- 4 files changed, 154 insertions(+), 64 deletions(-) diff --git a/pkg/apiserver/slowquery/queries.go b/pkg/apiserver/slowquery/queries.go index f200e80431..6b356cd4ed 100644 --- a/pkg/apiserver/slowquery/queries.go +++ b/pkg/apiserver/slowquery/queries.go @@ -37,11 +37,18 @@ type SlowQuery struct { ConnectionID string `gorm:"column:Conn_ID" json:"connection_id"` Success int `gorm:"column:Succ" json:"success"` - Timestamp float64 `gorm:"column:timestamp" proj:"(UNIX_TIMESTAMP(Time) + 0E0)" json:"timestamp"` // finish time - QueryTime float64 `gorm:"column:Query_time" json:"query_time"` // latency - ParseTime float64 `gorm:"column:Parse_time" json:"parse_time"` - CompileTime float64 `gorm:"column:Compile_time" json:"compile_time"` - ProcessTime float64 `gorm:"column:Process_time" json:"process_time"` + Timestamp float64 `gorm:"column:timestamp" proj:"(UNIX_TIMESTAMP(Time) + 0E0)" json:"timestamp"` // finish time + QueryTime float64 `gorm:"column:Query_time" json:"query_time"` // latency + ParseTime float64 `gorm:"column:Parse_time" json:"parse_time"` + CompileTime float64 `gorm:"column:Compile_time" json:"compile_time"` + RewriteTime float64 `gorm:"column:Rewrite_time" json:"rewrite_time"` + PreprocSubqueriesTime float64 `gorm:"column:Preproc_subqueries_time" json:"preproc_subqueries_time"` + OptimizeTime float64 `gorm:"column:Optimize_time" json:"optimize_time"` + WaitTSTime float64 `gorm:"column:Wait_TS" json:"wait_ts"` + CopTime float64 `gorm:"column:Cop_time" json:"cop_time"` + LockKeysTime float64 `gorm:"column:LockKeys_time" json:"lock_keys_time"` + WriteRespTime float64 `gorm:"column:Write_sql_response_total" json:"write_sql_response_total"` + ExecRetryTime float64 `gorm:"column:Exec_retry_time" json:"exec_retry_time"` MemoryMax int `gorm:"column:Mem_max" json:"memory_max"` DiskMax int `gorm:"column:Disk_max" json:"disk_max"` @@ -63,20 +70,22 @@ type SlowQuery struct { Host string `gorm:"column:Host" json:"host"` // Time - WaitTime float64 `gorm:"column:Wait_time" json:"wait_time"` - BackoffTime float64 `gorm:"column:Backoff_time" json:"backoff_time"` - GetCommitTSTime float64 `gorm:"column:Get_commit_ts_time" json:"get_commit_ts_time"` - LocalLatchWaitTime float64 `gorm:"column:Local_latch_wait_time" json:"local_latch_wait_time"` - ResolveLockTime float64 `gorm:"column:Resolve_lock_time" json:"resolve_lock_time"` - PrewriteTime float64 `gorm:"column:Prewrite_time" json:"prewrite_time"` - CommitTime float64 `gorm:"column:Commit_time" json:"commit_time"` - CommitBackoffTime float64 `gorm:"column:Commit_backoff_time" json:"commit_backoff_time"` - CopProcAvg float64 `gorm:"column:Cop_proc_avg" json:"cop_proc_avg"` - CopProcP90 float64 `gorm:"column:Cop_proc_p90" json:"cop_proc_p90"` - CopProcMax float64 `gorm:"column:Cop_proc_max" json:"cop_proc_max"` - CopWaitAvg float64 `gorm:"column:Cop_wait_avg" json:"cop_wait_avg"` - CopWaitP90 float64 `gorm:"column:Cop_wait_p90" json:"cop_wait_p90"` - CopWaitMax float64 `gorm:"column:Cop_wait_max" json:"cop_wait_max"` + ProcessTime float64 `gorm:"column:Process_time" json:"process_time"` + WaitTime float64 `gorm:"column:Wait_time" json:"wait_time"` + BackoffTime float64 `gorm:"column:Backoff_time" json:"backoff_time"` + GetCommitTSTime float64 `gorm:"column:Get_commit_ts_time" json:"get_commit_ts_time"` + LocalLatchWaitTime float64 `gorm:"column:Local_latch_wait_time" json:"local_latch_wait_time"` + ResolveLockTime float64 `gorm:"column:Resolve_lock_time" json:"resolve_lock_time"` + PrewriteTime float64 `gorm:"column:Prewrite_time" json:"prewrite_time"` + WaitPreWriteBinlogTime float64 `gorm:"column:Wait_prewrite_binlog_time" json:"wait_prewrite_binlog_time"` + CommitTime float64 `gorm:"column:Commit_time" json:"commit_time"` + CommitBackoffTime float64 `gorm:"column:Commit_backoff_time" json:"commit_backoff_time"` + CopProcAvg float64 `gorm:"column:Cop_proc_avg" json:"cop_proc_avg"` + CopProcP90 float64 `gorm:"column:Cop_proc_p90" json:"cop_proc_p90"` + CopProcMax float64 `gorm:"column:Cop_proc_max" json:"cop_proc_max"` + CopWaitAvg float64 `gorm:"column:Cop_wait_avg" json:"cop_wait_avg"` + CopWaitP90 float64 `gorm:"column:Cop_wait_p90" json:"cop_wait_p90"` + CopWaitMax float64 `gorm:"column:Cop_wait_max" json:"cop_wait_max"` // Transaction WriteKeys int `gorm:"column:Write_keys" json:"write_keys"` diff --git a/ui/lib/apps/SlowQuery/pages/Detail/DetailTabTime.tsx b/ui/lib/apps/SlowQuery/pages/Detail/DetailTabTime.tsx index 222ccabd18..07c68758da 100644 --- a/ui/lib/apps/SlowQuery/pages/Detail/DetailTabTime.tsx +++ b/ui/lib/apps/SlowQuery/pages/Detail/DetailTabTime.tsx @@ -12,6 +12,15 @@ export interface ITabTimeProps { export default function TabBasic({ data }: ITabTimeProps) { const { t } = useTranslation() const items = [ + { + key: 'query_time2', + keyDisplay: ( + + {t('slow_query.fields.query_time2')} + + ), + value: data.query_time! * 10e8, + }, { key: 'parse_time', value: data.parse_time! * 10e8, @@ -20,6 +29,26 @@ export default function TabBasic({ data }: ITabTimeProps) { key: 'compile_time', value: data.compile_time! * 10e8, }, + { + key: 'rewrite_time', + value: data.rewrite_time! * 10e8, + }, + { + key: 'preproc_subqueries_time', + value: data.preproc_subqueries_time! * 10e8, + }, + { + key: 'optimize_time', + value: data.optimize_time! * 10e8, + }, + { + key: 'wait_ts', + value: data.wait_ts! * 10e8, + }, + { + key: 'cop_time', + value: data.cop_time! * 10e8, + }, { key: 'wait_time', value: data.wait_time! * 10e8, @@ -28,42 +57,49 @@ export default function TabBasic({ data }: ITabTimeProps) { key: 'process_time', value: data.process_time! * 10e8, }, + { + key: 'lock_keys_time', + value: data.lock_keys_time! * 10e8, + }, { key: 'backoff_time', value: data.backoff_time! * 10e8, }, { - key: 'get_commit_ts_time', - value: data.get_commit_ts_time! * 10e8, + key: 'prewrite_time', + value: data.prewrite_time! * 10e8, }, { key: 'local_latch_wait_time', value: data.local_latch_wait_time! * 10e8, }, { - key: 'resolve_lock_time', - value: data.resolve_lock_time! * 10e8, + key: 'wait_prewrite_binlog_time', + value: data.wait_prewrite_binlog_time! * 10e8, }, { - key: 'prewrite_time', - value: data.prewrite_time! * 10e8, + key: 'get_commit_ts_time', + value: data.get_commit_ts_time! * 10e8, }, { key: 'commit_time', value: data.commit_time! * 10e8, }, + { + key: 'resolve_lock_time', + value: data.resolve_lock_time! * 10e8, + }, { key: 'commit_backoff_time', value: data.commit_backoff_time! * 10e8, }, { - key: 'query_time2', - keyDisplay: ( - - {t('slow_query.fields.query_time2')} - - ), - value: data.query_time! * 10e8, + key: 'exec_retry_time', + value: data.exec_retry_time! * 10e8, + }, + { + key: 'write_sql_response_total', + value: data.write_sql_response_total! * 10e8, }, ] const columns = timeValueColumns('slow_query.fields.', items) diff --git a/ui/lib/apps/SlowQuery/translations/en.yaml b/ui/lib/apps/SlowQuery/translations/en.yaml index f59f30746e..e6b37792dd 100644 --- a/ui/lib/apps/SlowQuery/translations/en.yaml +++ b/ui/lib/apps/SlowQuery/translations/en.yaml @@ -34,22 +34,45 @@ slow_query: db: Execution Database db_tooltip: The database used to execute the query - parse_time: Parse Time - parse_time_tooltip: Time consumed when parsing the query - compile_time: Compile Time - compile_time_tooltip: Time consumed when optimizing the query - wait_time: Coprocessor Wait Time - process_time: Coprocessor Process Time - backoff_time: Backoff Retry Time - backoff_time_tooltip: The waiting time before retry when a query encounters errors that require a retry - get_commit_ts_time: Get Commit Ts Time - local_latch_wait_time: Local Latch Wait Time - resolve_lock_time: Resolve Lock Time - prewrite_time: Prewrite Time - commit_time: Commit Time - commit_backoff_time: Commit Backoff Time query_time2: Query Time - query_time2_tooltip: The execution time of a query (due to the parallel execution, it may be significantly smaller than the above time) + query_time2_tooltip: The elapsed wall time when execution the query + parse_time:   Parse Time + parse_time_tooltip: Time consumed when parsing the query + compile_time:   Generate Plan Time + rewrite_time:     Rewrite Plan Time + preproc_subqueries_time:       Preprocess Sub-Query Time + preproc_subqueries_time_tooltip: Time consumed when pre-processing the subquery during the rewrite plan phase + optimize_time:     Optimize Plan Time + wait_ts:   Get Start Ts Time + wait_ts_tooltip: Time consumed of retrieving the transaction start timestamp when transaction begins + cop_time:   Coprocessor Executor Time + cop_time_tooltip: 'The elapsed wall time when TiDB Coprocessor executor waiting all Coprocessor requests to finish (note: when there are JOIN in SQL statement, multiple TiDB Coprocessor executors may be running in parallel, which may cause this time not being a wall time)' + wait_time:     Coprocessor Wait Time + wait_time_tooltip: The total waiting time of Coprocessor request in TiKV + process_time:     Coprocessor Process Time + process_time_tooltip: 'The total time of Coprocessor request being executed in TiKV (note: TiKV executes requests in parallel so that this is not a wall time)' + backoff_time:   Backoff Retry Time + backoff_time_tooltip: 'The total waiting time before retry when a query encounters errors and requires a retry (note: there may be multiple backoff running in parallel so that this may not be a wall time)' + lock_keys_time:   Lock Keys Time + lock_keys_time_tooltip: Time consumed when locking keys in pessimistic transaction + get_commit_ts_time:   Get Commit Ts Time + get_commit_ts_time_tooltip: Time consumed when getting a commit timestamp for 2PC commit phase when transaction commits + local_latch_wait_time:   Local Latch Wait Time + local_latch_wait_time_tooltip: Time consumed when TiDB waits for the lock in the current TiDB instance before 2PC commit phase when transaction commits + resolve_lock_time:   Resolve Lock Time + resolve_lock_time_tooltip: Time consumed when TiDB resolves locks from other transactions in 2PC prewrite phase when transaction commits + prewrite_time:   Prewrite Time + prewrite_time_tooltip: Time consumed in 2PC prewrite phase when transaction commits + wait_prewrite_binlog_time:   Wait Binlog Prewrite Time + wait_prewrite_binlog_time_tooltip: Time consumed when waiting Binlog prewrite to finish + commit_time:   Commit Time + commit_time_tooltip: Time consumed in 2PC commit phase when transaction commits + commit_backoff_time:   Commit Backoff Time + commit_backoff_time_tooltip: Total backoff waiting time when 2PC commit encounters errors when transaction commits + write_sql_response_total:   Send response Time + write_sql_response_total_tooltip: Time consumed when sending response to the SQL client + exec_retry_time:   Retry execution Time + exec_retry_time_tooltip: Time consumed when retrying the SQL statement execution caused by locks or errors request_count: Request Count process_keys: Process Keys diff --git a/ui/lib/apps/SlowQuery/translations/zh.yaml b/ui/lib/apps/SlowQuery/translations/zh.yaml index f1521f82dd..d5c46b20df 100644 --- a/ui/lib/apps/SlowQuery/translations/zh.yaml +++ b/ui/lib/apps/SlowQuery/translations/zh.yaml @@ -34,25 +34,47 @@ slow_query: db: 执行数据库 db_tooltip: 执行该 SQL 查询时使用的数据库名称 - parse_time: 解析耗时 + query_time2: SQL 执行时间 + query_time2_tooltip: 执行 SQL 耗费的自然时间 + parse_time:   解析耗时 parse_time_tooltip: 解析该 SQL 查询的耗时 - compile_time: 优化耗时 - compile_time_tooltip: 优化该 SQL 查询的耗时 - wait_time: Coprocessor 累计等待耗时 - process_time: Coprocessor 累计执行耗时 - process_time_tooltip: Coprocessor 累计执行耗时 - backoff_time: 累计重试等待耗时 - get_commit_ts_time: 取 Commit Ts 耗时 - get_commit_ts_time_tooltip: 从 PD 取递交时间戳(事务号)步骤的耗时 - local_latch_wait_time: Local Latch Wait 耗时 + compile_time:   生成执行计划耗时 + compile_time_tooltip: 生成该 SQL 的执行计划的耗时 + rewrite_time:     重写执行计划耗时 + rewrite_time_tooltip: 重写执行计划的耗时,例如常量折叠等 + preproc_subqueries_time:       子查询预处理耗时 + optimize_time:     优化执行计划耗时 + optimize_time_tooltip: 优化器寻找执行计划的耗时,包括规则优化和物理优化的耗时 + wait_ts:   取事务 Start Ts 耗时 + wait_ts_tooltip: 从 PD 取事务开始时间戳步骤的耗时 + cop_time:   Coprocessor 执行耗时 + cop_time_tooltip: TiDB Coprocessor 算子等待所有任务在 TiKV 上并行执行完毕耗费的自然时间(注:当 SQL 语句中包含 JOIN 时,多个 TiDB Coprocessor 算子可能会并行执行,此时不再等同于自然时间) + wait_time:     Coprocessor 累计等待耗时 + wait_time_tooltip: TiKV 准备并等待 Coprocessor 任务执行的累计时间 + process_time:     Coprocessor 累计执行耗时 + process_time_tooltip: TiKV 执行 Coprocessor 任务的累计处理时间(注:TiKV 会并行处理请求,该时间不是自然流逝时间) + lock_keys_time:   上锁耗时 + lock_keys_time_tooltip: 悲观事务中对相关行数据进行上锁的耗时 + backoff_time:   累计重试等待耗时 + backoff_time_tooltip: 执行过程中遇到锁或者错误后的累计等待耗时(注:可能同时存在多个重试等待,因此该时间可能不是自然流逝时间) + get_commit_ts_time:   取事务 Commit Ts 耗时 + get_commit_ts_time_tooltip: 从 PD 取提交时间戳(事务号)步骤的耗时 + local_latch_wait_time:   Local Latch Wait 耗时 local_latch_wait_time_tooltip: 事务在 TiDB 本地与其他事务产生了锁冲突并等待的耗时 - resolve_lock_time: Resolve Lock 耗时 - resolve_lock_time_tooltip: 事务在 TiKV 与其他事务产生了锁冲突并处理锁冲突的耗时 - prewrite_time: Prewrite 阶段耗时 - commit_time: Commit 阶段耗时 - commit_backoff_time: Commit 重试等待耗时 - query_time2: SQL 执行时间 - query_time2_tooltip: 由于存在并行执行,因此 SQL 执行时间可能远小于上述各项时间 + resolve_lock_time:   Resolve Lock 耗时 + resolve_lock_time_tooltip: 事务在提交过程中与其他事务产生了锁冲突并处理锁冲突的耗时 + prewrite_time:   Prewrite 阶段耗时 + prewrite_time_tooltip: 事务两阶段提交中第一阶段(prewrite 阶段)的耗时 + wait_prewrite_binlog_time:   Binlog Prewrite 等待耗时 + wait_prewrite_binlog_time_tooltip: 等待 Binlog Prewrite 完成的耗时 + commit_time:   Commit 阶段耗时 + commit_time_tooltip: 事务两阶段提交中第二阶段(commit 阶段)的耗时 + commit_backoff_time:   Commit 重试等待耗时 + commit_backoff_time_tooltip: 事务两阶段提交过程中遇到锁或者错误后的等待耗时 + write_sql_response_total:   发送结果耗时 + write_sql_response_total_tooltip: 发送 SQL 结果给客户端的耗时 + exec_retry_time:   执行重试耗时 + exec_retry_time_tooltip: 由于锁冲突或者某些错误导致执行失败的执行耗时 request_count: Coprocessor 请求数 process_keys: 可见版本数