From 3b1c3e950dc198c2246d6b797877d8fef95ca41f Mon Sep 17 00:00:00 2001 From: "jingshun.tq" <35712518+Teingi@users.noreply.github.com> Date: Wed, 16 Oct 2024 10:58:04 +0800 Subject: [PATCH] [fix] display SQL (#483) * gather scene run add --skip_type option * close #279 * fix * fix * fix * fix #382 * update readme * remove invalid option * fix display sql * fix display sql --- handler/display/tasks/observer/event.yaml | 4 ++-- handler/display/tasks/observer/table_info.yaml | 14 +++++++------- handler/display/tasks/observer/topsql.yaml | 5 ++++- handler/display/tasks/observer/zone_info.yaml | 3 ++- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/handler/display/tasks/observer/event.yaml b/handler/display/tasks/observer/event.yaml index cc40a67..45c8bf9 100644 --- a/handler/display/tasks/observer/event.yaml +++ b/handler/display/tasks/observer/event.yaml @@ -27,9 +27,9 @@ task: SUM(total_waits) AS total_waits, SUM(time_waited_micro / 1000000) AS time_waited FROM - v$system_event + oceanbase.v$system_event WHERE - v$system_event.wait_class <> 'IDLE' + oceanbase.v$system_event.wait_class <> 'IDLE' AND ( con_id > 1000 OR con_id = 1 diff --git a/handler/display/tasks/observer/table_info.yaml b/handler/display/tasks/observer/table_info.yaml index ee89ef7..c66db39 100644 --- a/handler/display/tasks/observer/table_info.yaml +++ b/handler/display/tasks/observer/table_info.yaml @@ -8,7 +8,7 @@ task: sql: "select /*+ READ_CONSISTENCY(WEAK) query_timeout(100000000)*/ table_schema, table_name, table_type, engine, row_format, table_rows, avg_row_length, table_collation from information_schema.tables where table_name = '{table_name}' and table_schema = '{database_name}';" global: true - type: sql - sql: "select /*+ READ_CONSISTENCY(WEAK) query_timeout(100000000)*/ dotl.database_name, dotl.table_name, dotl.ls_id, dotl.zone, dotl.svr_ip, dotl.svr_port, dotl.role, dotl.replica_type from dba_ob_table_locations dotl where dotl.table_name = '{table_name}' and dotl.database_name = '{database_name}';" + sql: "select /*+ READ_CONSISTENCY(WEAK) query_timeout(100000000)*/ dotl.database_name, dotl.table_name, dotl.ls_id, dotl.zone, dotl.svr_ip, dotl.svr_port, dotl.role, dotl.replica_type from oceanbase.dba_ob_table_locations dotl where dotl.table_name = '{table_name}' and dotl.database_name = '{database_name}';" global: true - type: sql sql: "select /*+ READ_CONSISTENCY(WEAK) query_timeout(100000000)*/ dotl.database_name, @@ -36,9 +36,9 @@ task: concat(round(sum(dotr.data_size/1024/1024/1024), 2), 'G') datasize_primary , concat(round(sum(dotr.required_size)/1024/1024/1024, 2), 'G') requiredsize_primary from - dba_ob_table_locations dotl, - dba_ob_tablet_replicas dotr, - dba_ob_table_locations dotl2 + oceanbase.dba_ob_table_locations dotl, + oceanbase.dba_ob_tablet_replicas dotr, + oceanbase.dba_ob_table_locations dotl2 where dotl.ls_id = dotl2.ls_id and dotl.svr_ip = dotl2.svr_ip and dotl.role = dotl2.role @@ -59,9 +59,9 @@ task: concat(round(sum(dotr.data_size/1024/1024/1024), 2), 'G') datasize_primary , concat(round(sum(dotr.required_size)/1024/1024/1024, 2), 'G') requiredsize_primary from - dba_ob_table_locations dotl, - dba_ob_tablet_replicas dotr, - dba_ob_table_locations dotl2 + oceanbase.dba_ob_table_locations dotl, + oceanbase.dba_ob_tablet_replicas dotr, + oceanbase.dba_ob_table_locations dotl2 where dotl.ls_id = dotl2.ls_id and dotl.svr_ip = dotl2.svr_ip and dotl.role = dotl2.role diff --git a/handler/display/tasks/observer/topsql.yaml b/handler/display/tasks/observer/topsql.yaml index ee0d2a2..c266e76 100644 --- a/handler/display/tasks/observer/topsql.yaml +++ b/handler/display/tasks/observer/topsql.yaml @@ -5,11 +5,14 @@ task: - version: "[4.0.0.0, *]" steps: - type: sql - sql: "select SQL_ID, count(*) as QPS, avg(t1.elapsed_time) RT + sql: "select tenant_name, SQL_ID, count(*) as QPS, avg(t1.ELAPSED_TIME) as ELAPSED_TIME_AVG, substr(query_sql,1,50) from oceanbase.gv$ob_sql_audit t1 where IS_EXECUTOR_RPC = 0 and request_time > (time_to_usec(now()) - {mtime} * 60 * 1000000) and request_time < time_to_usec(now()) + and length(query_sql) > 0 + and IS_INNER_SQL = 0 + and length(sql_id) > 0 group by t1.sql_id order by QPS desc limit 10;" global: true diff --git a/handler/display/tasks/observer/zone_info.yaml b/handler/display/tasks/observer/zone_info.yaml index 1c03233..e8e203a 100644 --- a/handler/display/tasks/observer/zone_info.yaml +++ b/handler/display/tasks/observer/zone_info.yaml @@ -5,4 +5,5 @@ task: - version: "[4.0.0.0, *]" steps: - type: sql - sql: "select * from oceanbase.dba_ob_zones;" \ No newline at end of file + sql: "select * from oceanbase.dba_ob_zones;" + global: true \ No newline at end of file