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/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 【實驗】【Tom】runstats工具使用演示
- runstats工具的配置及使用
- tom的runstats_pkg工具包關於批次插入和繫結變數分析-01變數
- tom的runstats_pkg工具包關於批次插入和繫結變數分析-02變數
- tom的runstats_pkg工具包關於批次插入和繫結變數分析-03變數
- 效能比較工具runStats_pkg
- Runstats 指令碼指令碼
- runstats安裝方法
- runstats_pkg包的安裝
- db2 reorg,runstatsDB2
- DB2 PL/SQL Example: RunstatsDB2SQL
- SQL最佳化好助手:RunstatsSQL
- tomcat 監控工具probeTomcat
- 自定義效能統計儲存過程包runstats儲存過程
- Android uiautomator自動化工具AndroidUI
- 公共資源情報(OSINT)工具Automater
- 推薦一款功能強大的Tomcat 管理監控工具,可替代Tomcat ManagerTomcat
- PhotoMill X for Mac圖片批次處理工具Mac
- Tomcat口令猜解工具【Python指令碼】TomcatPython指令碼
- 用UiAutomator測試工具模擬輸入操作的幾種方式UI
- Android測試工具 UIAutomator入門與介紹AndroidUI
- 使用cronolog工具給tomcat進行日誌切割Tomcat
- tomcat記憶體溢位問題監控工具Tomcat記憶體溢位
- SAP Cloud for Customer和SAP Fiori系統裡的OData測試工具Cloud
- 關於Tomcat效能監控的第三方工具Probe的簡介Tomcat
- 菜鳥教程之工具使用(五)——JRebel與Windows服務的Tomcat整合WindowsTomcat
- appium uiautomator 移動端自動化測試工具APPUI
- [OC]之 atomic 與 nonatomic的區別
- Automatic Duck Xsend Motion Mac(fcpx專案轉換Motion工具)Mac
- 幾款前端IDE工具:Sublime、Atom、VSCode比較前端IDEVSCode
- 菜鳥教程之工具使用(三)——Maven自動部署到TomcatMavenTomcat
- SAP Cloud for Customer的Mashup位於CustomPane裡Cloud
- 對CustomHTTPProtocol的理解HTTPProtocol
- 使用微軟RPA工具 Power Automate自動完成重複性工作微軟
- solidity智慧合約開發工具Atom及其外掛安裝Solid
- phantomjs實現免費線上網頁截圖工具-toolfk程式設計師線上工具網JS網頁程式設計師
- Websocket:TomCat7 與 TomCat8的區別WebTomcat
- [Web][Tomcat]Tomcat相關WebTomcat