Tom的runstats工具
Tom的runstat工具可以比較同一事件的兩種方法,得出那種方法較好,runstat工具的建立過程如下:
1.要確認有訪問v$statname、v$mystat、v$latch和v$timer檢視的許可權
2.建立臨時表,儲存統計資料
create global temporary table run_stats
( runid varchar2(15),
name varchar2(80),
value int )
on commit preserve rows;
3.建立檢視,用於提取統計資料
create or replace view stats
as select 'STAT...' || a.name name, b.value
from v$statname a, v$mystat b
where a.statistic# = b.statistic#
union all
select 'LATCH.' || name, gets
from v$latch
union all
select 'STAT...Elapsed Time', hsecs from v$timer;
4.建立過程體和rs_start、rs_middle、rs_stop過程,其中
rs_start在第一種方法執行前使用
rs_middle在第二種方法執行前使用
rs_stop在第二種方法執行後使用
create or replace package body runstats_pkg
as
g_start number;
g_run1 number;
g_run2 number;
procedure rs_start
is
begin
delete from run_stats;
insert into run_stats
select 'before', stats.* from stats;
g_start := dbms_utility.get_time;
end;
procedure rs_middle
is
begin
g_run1 := (dbms_utility.get_time-g_start);
insert into run_stats
select 'after 1', stats.* from stats;
g_start := dbms_utility.get_time;
end;
procedure rs_stop(p_difference_threshold in number default 0)
is
begin
g_run2 := (dbms_utility.get_time-g_start);
dbms_output.put_line
( 'Run1 ran in ' || g_run1 || ' hsecs' );
dbms_output.put_line
( 'Run2 ran in ' || g_run2 || ' hsecs' );
dbms_output.put_line
( 'run 1 ran in ' || round(g_run1/g_run2*100,2) ||
'% of the time' );
dbms_output.put_line( chr(9) );
insert into run_stats
select 'after 2', stats.* from stats;
dbms_output.put_line
( rpad( 'Name', 30 ) || lpad( 'Run1', 12 ) ||
lpad( 'Run2', 12 ) || lpad( 'Diff', 12 ) );
for x in
( select rpad( a.name, 30 ) ||
to_char( b.value-a.value, '999,999,999' ) ||
to_char( c.value-b.value, '999,999,999' ) ||
to_char( ( (c.value-b.value)-(b.value-a.value)), '999,999,999' ) data
from run_stats a, run_stats b, run_stats c
where a.name = b.name
and b.name = c.name
and a.runid = 'before'
and b.runid = 'after 1'
and c.runid = 'after 2'
-- and (c.value-a.value) > 0
and abs( (c.value-b.value) - (b.value-a.value) )
> p_difference_threshold
order by abs( (c.value-b.value)-(b.value-a.value))
) loop
dbms_output.put_line( x.data );
end loop;
dbms_output.put_line( chr(9) );
dbms_output.put_line
( 'Run1 latches total versus runs -- difference and pct' );
dbms_output.put_line
( lpad( 'Run1', 12 ) || lpad( 'Run2', 12 ) ||
lpad( 'Diff', 12 ) || lpad( 'Pct', 10 ) );
for x in
( select to_char( run1, '999,999,999' ) ||
to_char( run2, '999,999,999' ) ||
to_char( diff, '999,999,999' ) ||
to_char( round( run1/run2*100,2 ), '99,999.99' ) || '%' data
from ( select sum(b.value-a.value) run1, sum(c.value-b.value) run2,
sum( (c.value-b.value)-(b.value-a.value)) diff
from run_stats a, run_stats b, run_stats c
where a.name = b.name
and b.name = c.name
and a.runid = 'before'
and b.runid = 'after 1'
and c.runid = 'after 2'
and a.name like 'LATCH%'
)
) loop
dbms_output.put_line( x.data );
end loop;
end;
end;
/
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/498744/viewspace-327384/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- runstats安裝方法
- db2 reorg,runstatsDB2
- 題目 1118: Tom數
- Jeff Bezos Has Nothing On Tom Nook
- TOM貓安卓市場整站程式安卓
- Web Socket 效能對比——Spring Boot vs TomWebSpring Boot
- We've all been spoiled by Tom Brady's tumble: for the vast majority of quarterbaAST
- An incompatible version 1.1.33 of the APR based Apache Tomcat Native library is installed, while TomApacheTomcatWhile
- 【譯】用maven使java web應用執行在內嵌的Jetty或TomMavenJavaWebJetty
- Fundstrat的Tom Lee表示:儘管市場艱難,比特幣仍是最好的選擇比特幣
- 服務、微服務與無伺服器之函式的區別? - Tom Nolle微服務伺服器函式
- Tom Gardner:2022年機械硬碟的容量密度停留在1.1Tb/英寸 不及2015年硬碟容量密度硬碟
- Tom’s Hardware:2020年度硬體 銳龍5 5600X獲頒最佳CPU
- 【工具】好用的密評工具CyberChef
- 最常用的scrum工具、敏捷開發工具、看板工具Scrum敏捷
- Tom’s Hareware:2022年6月1日到15日美國市場新卡價格平均降價幅度2%
- 很好用的壓測工具 - Apache Bench工具Apache
- 免費的FTP工具,免費的FTP工具下載!FTP
- ios 常用的工具iOS
- dumpbin工具的使用
- doDBA工具的使用
- ftp工具,6款好用的ftp工具,來自運維人員好用的ftp工具推薦。FTP運維
- 實現工具自由,開源的桌面工具箱
- 工具篇:介紹幾個好用的guava工具類Guava
- Caffeinated 6.828:使用的工具
- Hadoop 工具的認識Hadoop
- 七仔的桌面工具
- windows中好用的工具Windows
- Metasploit profiling工具的利用
- 好用的工具推薦
- 好用的工具包
- 『政善治』Postman工具 — 14、NewMan工具的使用詳解Postman
- 【工具篇】最流行的Web漏洞掃描工具推薦!Web
- python常用的影像處理工具有哪些?工具推薦!Python
- Golang工具集-String工具,時間工具,http工具等GolangHTTP
- DDD不是開發人員的工具,而是系統設計的工具 - ntcoding
- 常用的SEO工具都有哪些呢?站長必備的5個SEO工具
- 列舉一些站長工具中常用的SEO工具
- 工具推薦:免費好用的WebP格式轉換工具:AnyWebPWeb