oracle分析工具dbms_profiler分析代碼
阿新 • • 發佈:2018-07-31
start total Owner dbm des home sub plsql type 執行前需要運行$ORACLE_HOME/rdbms/admin/proftab.sql 創建一些關鍵表.
BEGIN
DBMS_PROFILER.START_PROFILER('MY_APPLICATION'||TO_CHAR(SYSDATE,'YYYYMMDD HH24:MI:SS'));
--執行程序
MY_APPLICATION_CODE;
DBMS_PROFILER.END_PROFILER;
END;
SELECT to_char(p1.total_time/10000000,'99999999')
||'-'
||to_char(p1.total_occur) AS time_count,
SUBSTR (p2.unit_owner,1,20)
||'.'
||DECODE(p2.unit_name,'','<anonymous>',SUBSTR(p2.unit_name,1,20))
AS unit,
to_char(p1.line#)|| '-'||p3.text text
FROM plsql_profiler_data p1
,plsql_profiler_units p2
,all_source p3
,(SELECT SUM(total_time) AS grand_total FROM plsql_profiler_units) p4
WHERE p2.unit_owner NOT IN('SYS','SYSTEM')
AND P1.RUNID=3
AND (P1.TOTAL_TIME >=P4.grand_total/100)
AND P1.RUNID=P2.RUNID
AND P2.UNIT_NUMBER=P1.UNIT_NUMBER
AND P3.TYPE='PACKAGE BODY'
AND P3.OWNER=P2.UNIT_OWNER
AND p3.line=p1.line#
AND p3.name=p2.unit_name
ORDER BY p1.total_time DESC;
oracle分析工具dbms_profiler分析代碼