Skip to content

Commit

Permalink
display function optimization (#682)
Browse files Browse the repository at this point in the history
* Rename Dockerfile to DockerFile

* add storage_method.yaml

* add storage_method.yaml

* display function optimization

* display function optimization
  • Loading branch information
Teingi authored Jan 14, 2025
1 parent 1fe786c commit cab9b3c
Show file tree
Hide file tree
Showing 13 changed files with 72 additions and 125 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
info_en: "[obtab]"
info_cn: "[ob内部表信息]"
command: obdiag display scene run --scene=observer.obtab --env tablename=test
info_en: "[inner_table]"
info_cn: "[内部表信息模糊匹配]"
command: obdiag display scene run --scene=observer.inner_table --env tablename=test
task:
- version: "[*,*]"
steps:
- type: sql
sql: "SELECT distinct table_name FROM oceanbase.__all_virtual_table t1 JOIN oceanbase.__all_virtual_database t2 ON t2.database_id = t1.database_id JOIN oceanbase.__all_tenant t3 ON t3.tenant_id = t1.tenant_id WHERE tenant_name = 'sys' AND database_name = 'oceanbase' AND (table_name LIKE '__all%' OR table_name LIKE '__tenant%' OR table_name LIKE 'gv%' OR table_name LIKE 'v%' OR table_name LIKE 'dba%' OR table_name LIKE 'cdb%') and table_name like '%#{tablename}%' ORDER BY ORA_DECODE(SUBSTR(table_name, 1, 1), 'v', 3, 'g', 4, ORA_DECODE(SUBSTR(table_name, 3, 1), 'a', 2, 1)), table_name;"
global: true
global: true
19 changes: 0 additions & 19 deletions plugins/display/tasks/observer/lock.yaml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
info_en: "[locktab]"
info_en: "[lock table]"
info_cn: "[某张表上持有锁的信息]"
command: obdiag display scene run --scene=observer.locktab --env tablename=test
command: obdiag display scene run --scene=observer.lock_table --env tablename=test
task:
- version: "[*,4.0.0]"
steps:
Expand Down
20 changes: 0 additions & 20 deletions plugins/display/tasks/observer/locked_session.yaml

This file was deleted.

27 changes: 14 additions & 13 deletions plugins/display/tasks/observer/lockholder.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
info_en: "[lock holder info]"
info_cn: "[查看锁等待]"
command: obdiag display scene run --scene=observer.lockholder --env db_connect='-h127.0.0.1 -P2881 -utest@test -p****** -Dtest'
command: obdiag display scene run --scene=observer.lockholder
task:
- version: "[4.0.0.0, *]"
- version: "[*,4.0.0]"
steps:
- type: sql
sql: " select /*+ READ_CONSISTENCY(WEAK) query_timeout(100000000)*/ concat(case block
when 0 then 'Holder:'
when 1 then 'Waiter:'
end, op.svr_ip, ':', op.id) as sess,
ol.id1, ol.id2, ol.lmode, ol.request, ol.type, round(ol.ctime/1000/1000,0) ctime, op.info, op.command, if(op.sql_id = '', 'NULL', op.sql_id) sql_id, do.owner, do.object_name
from oceanbase.gv$ob_locks ol, oceanbase.gv$ob_processlist op, oceanbase.dba_objects do,
(select id1, id2, type from oceanbase.gv$ob_locks where type = 'TR' and block = 1) l
where ol.id1 = l.id1 and ol.id2= l.id2
and ol.trans_id = op.trans_id
and ol.id1 = do.data_object_id
order by id1, id2, ctime desc, block asc;"
sql: "select distinct a.svr_ip,c.table_id table_actual_id,c.table_name,a.session_id,a.block_session_id,a.lock_mode,a.type
from oceanbase.__all_virtual_lock_wait_stat a
left join oceanbase.__all_virtual_table c on a.table_id=c.table_id order by c.table_name;"
global: true
- version: "[4.0.0,*]"
steps:
- type: sql
sql: "select distinct a.tenant_id,a.svr_ip,c.table_id table_actual_id,c.table_name,a.tablet_id,a.session_id,a.block_session_id,a.trans_id,
a.holder_trans_id,a.lock_mode,a.type
from oceanbase.__all_virtual_lock_wait_stat a
left join oceanbase.__all_virtual_tablet_to_ls b on b.tablet_id=a.tablet_id and a.tenant_id=b.tenant_id and a.ls_id=b.ls_id
left join oceanbase.__all_virtual_table c on b.table_id=c.table_id order by c.table_name,a.tenant_id;"
global: true
4 changes: 2 additions & 2 deletions plugins/display/tasks/observer/long_transaction.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
info_en: "[long_transaction]"
info_cn: "[ob集群的长事务信息]"
command: obdiag display scene run --scene=observer.long_transaction --env wait_time= waittime(s)
info_cn: "[集群的长事务信息]"
command: obdiag display scene run --scene=observer.long_transaction --env wait_time=waittime(s)
task:
- version: "[*,4.0.0]"
steps:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
info_en: "[mem]"
info_cn: "[所有tenant的mermory信息]"
command: obdiag display scene run --scene=observer.mem
info_en: "[mermory]"
info_cn: "[所有租户的 mermory 信息]"
command: obdiag display scene run --scene=observer.mermory
task:
- version: "[4.0.0.0,*]"
steps:
Expand Down
3 changes: 1 addition & 2 deletions plugins/display/tasks/observer/processlist.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
info_en: "[processlist]"
info_cn: "[查看processlist]"
info_cn: "[查看 processlist]"
command: obdiag display scene run --scene=observer.processlist --env tenant_name=test
task:
- version: "[4.0.0.0, *]"
Expand All @@ -12,4 +12,3 @@ task:
- type: sql
sql: "select * from oceanbase.__all_virtual_processlist where tenant='#{tenant_name}';"
global: true

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
info_en: "[lvss]"
info_cn: "[processlist实时会话信息汇总]"
command: obdiag display scene run --scene=observer.lvss
info_en: "[processlist_stat]"
info_cn: "[processlist 实时会话信息汇总]"
command: obdiag display scene run --scene=observer.processlist_stat
task:
- version: "[*,3.0.0.0]"
steps:
Expand Down
4 changes: 2 additions & 2 deletions plugins/display/tasks/observer/rs.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
info_en: "[rs]"
info_cn: "[查看rootservice信息]"
info_cn: "[查看 rootservice 信息]"
command: obdiag display scene run --scene=observer.rs
task:
- version: "[4.0.0.0, *]"
Expand All @@ -17,4 +17,4 @@ task:
global: true
- type: sql
sql: "select * from oceanbase.__all_rootservice_event_history order by 1 desc limit 10;"
global: true
global: true
14 changes: 7 additions & 7 deletions plugins/display/tasks/observer/server_info.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ info_en: "[server info]"
info_cn: "[server 信息展示]"
command: obdiag display scene run --scene=observer.server_info
task:
- version: "[4.0.0.0, *]"
- version: "[*,*]"
steps:
- type: sql
sql: "SELECT /*+READ_CONSISTENCY(WEAK), QUERY_TIMEOUT(100000000)*/ zone, svr_ip, with_rootserver rs, case when start_service_time = 0 then NULL else CAST(usec_to_time(start_service_time) AS DATETIME) end start_service_time, case when stop_time = 0 then NULL else CAST(usec_to_time(stop_time) AS DATETIME) end stop_time, case when last_offline_time = 0 then NULL else CAST(usec_to_time(last_offline_time) AS DATETIME) end last_offline_time, status, SUBSTR(build_version, 1, INSTR(build_version, '-') - 1) build_version FROM oceanbase.__all_server order by zone, svr_ip;"
global: true
- version: "[3.0.0.0, 4.0.0.0]"
steps:
- type: sql
sql: "SELECT /*+READ_CONSISTENCY(WEAK), QUERY_TIMEOUT(100000000)*/ zone, svr_ip, with_rootserver rs, case when start_service_time = 0 then NULL else CAST(usec_to_time(start_service_time) AS DATETIME) end start_service_time, case when stop_time = 0 then NULL else CAST(usec_to_time(stop_time) AS DATETIME) end stop_time, case when last_offline_time = 0 then NULL else CAST(usec_to_time(last_offline_time) AS DATETIME) end last_offline_time, status, SUBSTR(build_version, 1, INSTR(build_version, '-') - 1) build_version FROM oceanbase.__all_server order by zone, svr_ip;"
sql: "select b.info cluster_name,a.svr_ip,a.with_rootserver rs,a.zone,
ora_decode(a.start_service_time,0,null,date_format(usec_to_time(a.start_service_time),'%Y-%m-%d %h:%i:%s')) start_service_time,
ora_decode(a.last_offline_time,0,null,date_format(usec_to_time(a.last_offline_time),'%Y-%m-%d %h:%i:%s')) last_offline_time,
ora_decode(a.stop_time,0,null,date_format(usec_to_time(a.stop_time),'%Y-%m-%d %h:%i:%s')) stop_time,
a.status,SUBSTR(a.build_version, 1, INSTR(build_version, '-') - 1) build_version
from oceanbase.__All_server a ,oceanbase.__all_zone b where b.name='cluster' order by a.zone,a.svr_ip; "
global: true
14 changes: 0 additions & 14 deletions plugins/display/tasks/observer/status.yaml

This file was deleted.

68 changes: 34 additions & 34 deletions plugins/display/tasks/observer/tabndv.yaml
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
info_en: "[tabndv]"
info_cn: "[查询表ndv信息]"
info_cn: "[查询表 ndv 信息]"
command: obdiag display scene run --scene=observer.tabndv --env user_name=test --env table_name=test
task:
- version: "[*,4.0.0.0]"
steps:
- type: sql
sql: "select t.database_name,
t.table_name,
c.column_name,
(case c.data_type
when 22 then 'VARCHAR2' when 17 then 'DATE' when 15 then 'NUMBER' when 38 then 'TIMESTAMP' when 30 then 'CLOB/BLOB' when 23 then 'CHAR' when 42 then 'FLOAT' when 39 then 'RAW' when 44 then 'NCHAR' when 43 then 'NVARCHAR2' else c.data_type end) AS COLUMN_TYPE,
SUM(s.num_distinct) as NDV,
sum(s.num_null) as num_null
from oceanbase.gv$table t
inner join oceanbase.__all_virtual_column c on t.table_id = c.table_id
inner join oceanbase.__all_virtual_column_statistic s on t.table_id = s.table_id and c.column_id = s.column_id
where t.table_name = upper('#{table_name}')
and t.database_name = upper('#{user_name}')
group by t.database_name, t.table_name, c.column_name,c.data_type;"
t.table_name,
c.column_name,
(case c.data_type
when 22 then 'VARCHAR2' when 17 then 'DATE' when 15 then 'NUMBER' when 38 then 'TIMESTAMP' when 30 then 'CLOB/BLOB' when 23 then 'CHAR' when 42 then 'FLOAT' when 39 then 'RAW' when 44 then 'NCHAR' when 43 then 'NVARCHAR2' else c.data_type end) AS COLUMN_TYPE,
SUM(s.num_distinct) as NDV,
sum(s.num_null) as num_null
from oceanbase.gv$table t
inner join oceanbase.__all_virtual_column c on t.table_id = c.table_id
inner join oceanbase.__all_virtual_column_statistic s on t.table_id = s.table_id and c.column_id = s.column_id
where t.table_name = upper('#{table_name}')
and t.database_name = upper('#{user_name}')
group by t.database_name, t.table_name, c.column_name,c.data_type;"
global: true
- type: sql
sql: "select a.svr_ip,
c.database_name,
tb.table_name,b.part_id,
b.part_name,b.part_high_bound part_high_value,b.part_func_type,b.subpart_id,b.subpart_name,b.subpart_high_bound subpart_high_value,b.subpart_func_type,
a.row_count
from oceanbase.__all_virtual_table tb join
oceanbase.__all_virtual_partition_table a on a.table_id = tb.table_id join
oceanbase.__all_virtual_database c on c.database_id = tb.database_id left join
oceanbase.__all_virtual_partition_item b on a.partition_id = b.partition_id and a.table_id = b.table_id
where tb.table_name = upper('#{table_name}')
and c.database_name = upper('#{user_name}') and a.role=1 order by 4,8;"
global: true
c.database_name,
tb.table_name,b.part_id,
b.part_name,b.part_high_bound part_high_value,b.part_func_type,b.subpart_id,b.subpart_name,b.subpart_high_bound subpart_high_value,b.subpart_func_type,
a.row_count
from oceanbase.__all_virtual_table tb join
oceanbase.__all_virtual_partition_table a on a.table_id = tb.table_id join
oceanbase.__all_virtual_database c on c.database_id = tb.database_id left join
oceanbase.__all_virtual_partition_item b on a.partition_id = b.partition_id and a.table_id = b.table_id
where tb.table_name = upper('#{table_name}')
and c.database_name = upper('#{user_name}') and a.role=1 order by 4,8;"
global: true

- version: "[4.0.0.0,*]"
steps:
- type: sql
sql: "select
s.OWNER,s.TABLE_NAME,s.COLUMN_NAME,s.NUM_DISTINCT as ndv,s.NUM_NULLS,s.LAST_ANALYZED,(case c.data_type
when 22 then 'VARCHAR2' when 17 then 'DATE' when 15 then 'NUMBER' when 38 then 'TIMESTAMP' when 30 then 'CLOB/BLOB' when 23 then 'CHAR' when 42 then 'FLOAT' when 39 then 'RAW' when 44 then 'NCHAR' when 43 then 'NVARCHAR2' else c.data_type end) AS COLUMN_TYPE
from oceanbase.CDB_TAB_COL_STATISTICS s
inner join oceanbase.__all_database d on s.OWNER=d.database_name
inner join oceanbase.__all_virtual_table t on s.TABLE_NAME=t.TABLE_NAME and s.CON_ID=t.tenant_id and d.database_id=t.database_id
inner join oceanbase.__all_virtual_column c on t.table_id = c.table_id and c.COLUMN_NAME=s.COLUMN_NAME
where s.table_name = upper('{#table_name}')
and s.OWNER=upper('#{user_name}');"
global: true
sql: "select
s.OWNER,s.TABLE_NAME,s.COLUMN_NAME,s.NUM_DISTINCT as ndv,s.NUM_NULLS,s.LAST_ANALYZED,(case c.data_type
when 22 then 'VARCHAR2' when 17 then 'DATE' when 15 then 'NUMBER' when 38 then 'TIMESTAMP' when 30 then 'CLOB/BLOB' when 23 then 'CHAR' when 42 then 'FLOAT' when 39 then 'RAW' when 44 then 'NCHAR' when 43 then 'NVARCHAR2' else c.data_type end) AS COLUMN_TYPE
from oceanbase.CDB_TAB_COL_STATISTICS s
inner join oceanbase.__all_database d on s.OWNER=d.database_name
inner join oceanbase.__all_virtual_table t on s.TABLE_NAME=t.TABLE_NAME and s.CON_ID=t.tenant_id and d.database_id=t.database_id
inner join oceanbase.__all_virtual_column c on t.table_id = c.table_id and c.COLUMN_NAME=s.COLUMN_NAME
where s.table_name = upper('{#table_name}')
and s.OWNER=upper('#{user_name}');"
global: true

0 comments on commit cab9b3c

Please sign in to comment.