http://blog.chinaunix.net/uid-74941-id-85352.html
https://www.bbsmax.com/A/MAzAgQNq59/
1.檢查是否安裝了dbms_profiler包
如果沒有安裝的話,執行下面的語句安裝,
@?/rdbms/admin/profload.sql
2.把dbms_profiler的執行權限賦于測試用戶scott
grant execute on dbms_profiler to scott;
3.使用測試用戶scott登錄,執行proftab.sql(創建跟蹤相關系統表)
@?/rdbms/admin/proftab.sql
4.創建一個測試的過程,
DMMS_PROFILER的用發:
(1).DBMS_PROFILER.start_profiler啟動監控
(2).運行所需要分析的存儲過程,可以是多個
(3).DBMS_PROFILER.stop_profiler結束監控
--創建測試存儲過程
create or replace procedure sp_profiler_test1
as
begin
for x in 1..10000
loop
insert into t_t1 values(x);
end loop;
commit;
end sp_profiler_test1;
/
--執行DMMS_PROFILER
set serverout on;
DECLARE
v_run_number integer;
BEGIN
--啟動profiler
sys.DBMS_PROFILER.start_profiler(run_number => v_run_number);
--顯示當前跟蹤的運行序號(后面查詢要用)
DBMS_OUTPUT.put_line('run_number:' || v_run_number);
--運行要跟蹤的PLSQL
sp_profiler_test1; --前一步創建的測試樣例存儲過程
--停止profiler
sys.DBMS_PROFILER.stop_profiler;
END;
/
5.查看結果
--使用測試用戶進行查詢
select d.line#, --源碼行號
s.text, --源碼
round(d.total_time/1000000000000,5) total_time , --總運行時間(單位秒)
d.total_occur, --總共運行次數
round(d.min_time/1000000000000,5) min_time, --單次最小運行時間
round(d.max_time/1000000000000,5) max_time --單次最大運行時間
from plsql_profiler_data d, sys.all_source s, plsql_profiler_units u
where d.runid = 2 --運行號
and u.unit_name = 'SP_PROFILER_TEST1' --單元名,即被測試的存儲過程名
and u.runid = d.runid
and d.unit_number = u.unit_number
and d.total_occur <> 0
and s.type(+) = u.unit_type
and s.owner(+) = u.unit_owner
and s.name(+) = u.unit_name
and d.line# = nvl(s.line, d.line#)
order by u.unit_number, d.line#;
1秒=1000毫秒bai(ms)
1秒=1,000,000 微秒(μdus)
1秒=1,000,000,000 納秒(ns)
1秒 =1,000,000,000,000 皮秒(ps) (單位10000億分之一秒)
1秒=1,000,000,000,000,000飛秒(fs)
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。