av一区二区在线观看_亚洲男人的天堂网站_日韩亚洲视频_在线成人免费_欧美日韩精品免费观看视频_久草视

您的位置:首頁技術(shù)文章
文章詳情頁

Oracle’s DBMS_Profiler:PL/SQL 性能調(diào)整

瀏覽:6日期:2023-11-18 17:08:56
Oracle’s DBMS_Profiler:PL/SQL 性能調(diào)整DBMS_PROFILER 包舉例 ;;;;下面是我提供的怎樣使用配置的簡單例子,運行配置文件來測試下面例程的性能. 例程用到的自定義腳本緊隨其后.1. 創(chuàng)建過程. create or replace procedure am_perf_chk (pi_seq;;in;number, ;pio_status in out nocopy varchar2) is ;;l_dat date := sysdate; begin ;;if trunc(l_dat) = '21-sep-02' and pi_seq = 1 then ;;;;pio_status := 'OK' ;;else ;;;;pio_status := 'Invalid tape loaded' ;;end if; exception ;;when others then ;;;;pio_status := 'Error in am_perf_chek' end; 2. 用配置文件調(diào)用例程 替換上面的例程, 執(zhí)行call_profiler.sql腳本(腳本代碼參見下面),傳入pi_seq=2 SQL> @d:amcall_profiler.sql Profiler started Invalid tape loaded PL/SQL procedure sUCcessfully completed. Profiler stopped Profiler flushed runid:8 3. 評估執(zhí)行時間:執(zhí)行eavluate_profiler_results.sql腳本,得到時間統(tǒng)計SQL> @d:amevaluate_profiler_results.sql Enter value for runid: 8 Enter value for name: am_perf_chk Enter value for owner: scott Line;;;Occur;;;;Msec Text---------- ---------- ---------- ------------------------------------------------------------------- 1;;;;procedure am_perf_chk (pi_seq;;in;number, 2;;;pio_status in out nocopy varchar2) is 3; 243.05965l_dat date := sysdate; 4;;;;begin 5; 186.35732if trunc(l_dat) = '21-sep-02' and pi_seq = 1 then 6; 0; 0;;pio_status := 'OK'; 7 else 8;;;;;;;18.416151;;pio_status := 'Invalid tape loaded'; 9 end if; 10;;;;exception 11 when others then 12; 0; 0;;pio_status := 'Error in am_perf_chek';! 13; 12.410361 end;13 rows selected.Code% coverage-------------- 66.66666674. 正如你看到的,第三行執(zhí)行時間提高到86毫秒.但是改變if語句,重新執(zhí)行上面的過程,將會得到新的結(jié)果: ;;;;;;Line;;;Occur;;;;Msec Text---------- ---------- ---------- ------------------------------------------------------------------- 1;;;;procedure am_perf_chk (pi_seq;;in;number, 2;;;pio_status in out nocopy varchar2) is 3; 2; 17.978816l_dat date := sysdate; 4;;;;begin 5; 18.419503if pi_seq = 1 and trunc(l_dat) = '21-sep-02' then 6; 0; 0;;pio_status := 'OK'; 7 else 8; 17.512684;;pio_status := 'Invalid tape loaded'; 9 end if; 10;;;;exception 11 when others then 12; 0; 0;;pio_status := 'Error in !am_perf_chek'; 13; 1;.731657 end;13 rows selected.Code% coverage-------------- 66.66666675. 正如你看到的, 這種情境下第三行執(zhí)行時間從86毫秒減少到8毫秒,多余的時間是由于內(nèi)置trunc()函數(shù)引起., 這種情境下假如第一個條件為false,則不會執(zhí)行trunc()函數(shù).這僅僅是個簡單的例子,當你測試的例程越大,你面臨的挑戰(zhàn)更大.這個配置結(jié)果也證實了執(zhí)行期間代碼被覆蓋多少行,從而讓我們知道處于性能監(jiān)視中的代碼范圍。 假如任何PL/SQL塊性能出現(xiàn)問題,它也能提煉出各種不同情景的正在在執(zhí)行的代碼并檢查配置結(jié)果,從而查明問題所在。6. 對于一個特定的情景,假如執(zhí)行一段非凡的代碼段,可以得到合理的分析,即使代碼根本一點都不能運行。環(huán)境的創(chuàng)建 默認安裝或數(shù)據(jù)庫的創(chuàng)建狀態(tài)下,DBMS_PROFILER包不會自動安裝,請DBA用profload.sql腳本創(chuàng)建它.用一個權(quán)限較大的或一個單獨的用戶,創(chuàng)建存儲統(tǒng)計信息的表。假如用如SYS用戶創(chuàng)建,則給其它用戶授予DML權(quán)限,并且對這些表創(chuàng)建一個共同的簡寫名. 創(chuàng)建表的如下: PLSQL_PROFILER_RUNS表:PL/SQL配置的運行細節(jié). PLSQL_PROFILER_UNITS表:運行中每一個庫單元的信息. PLSQL_PROFILER_DATA表:所有配置文件運行時的數(shù)據(jù)累積. PLSQL_PROFILER_RUNNUMBER序列提供了RUNID運行和解釋配置數(shù)據(jù) ORACLE提供了三個表來統(tǒng)計,填充RUNID。有許多第三方的工具可以提供自定義的基于這些數(shù)據(jù)的報告,ORACLE提供profrep.sql腳本評估數(shù)據(jù)(在<oracle_home>plsqldemo目錄下),下面的兩個簡單腳本就是上面用到的,用來檢查程序單元的執(zhí)行時間.執(zhí)行時間以毫秒存儲 -----------------------------------------------------------Script: call_profiler.sql-----------------------------------------------------------set head offset pages 0select decode(dbms_profiler.start_profiler, '0', 'Profiler started', 'Profiler error')fromdual;--< place your routine in the below block >-- declare l_status varchar2(200);begin am_perf_chk(2, l_status); dbms_output.put_line(l_status);end;/select decode(dbms_profiler.stop_profiler, '0', 'Profiler stopped', 'Profiler error')fromdual;select decode(dbms_profiler.flush_data, '0', 'Profiler flushed', 'Profiler error')fromdual;select 'runid:' plsql_profiler_runnumber.currval fromdual;set head onset pages 200-----------------------------------------------------------Script: evaluate_profiler_results.sql-----------------------------------------------------------undef runidundef ownerundef nameset verify offselect s.line 'Line', p.total_occur 'Occur', p.total_time 'Msec', s.text 'Text'fromall_source s, (select u.unit_owner, u.unit_name, u.unit_type, d.line#, d.total_occur, d.total_time/1000000 total_time fromplsql_profiler_data d, plsql_profiler_units u where; u.runid = &&runid and;u.runid = d.runid and;u.unit_number = d.unit_number) pwhere; s.owner = p.unit_owner (+)and;s.name = p.unit_name (+)and;s.type = p.unit_type (+)and;s.line = p.line# (+)and;s.name = upper('&&name')and;s.owner = upper('&&owner')order by s.line;select exec.cnt/total.cnt * 100 'Code% coverage'from; (select count(1) cnt from plsql_profiler_data d, plsql_profiler_units u where d.runid = &&runid and u.runid = d.runid and u.unit_number = d.unit_number ;;;;;and u.unit_name = upper('&&name') and u.unit_owner = upper('&&owner')) total, (select count(1) cnt from plsql_profiler_data d, plsql_profiler_units u where d.runid = &&runid and u.runid = d.runid and u.unit_number = d.unit_number and u.unit_name = upper('&&name') and u.unit_owner = upper('&&owner') and d.total_occur > 0) exec;undef runidundef ownerundef name結(jié)論 DBMS_PROFILER是非常強大的工具,其一就是可以識別PL/SQL的性能問題.這個工具最好用在開發(fā)時期,用來調(diào)整基于各種應(yīng)用的情景的代碼,它也能用很好的調(diào)整已在使用中的例程并且采取顯而易見的時間去執(zhí)行。 總之,這個工具可以給每一行代碼給予性能統(tǒng)計,它可以幫助我們評估和調(diào)整到一個出色的水平,當檢查SQL語句的性能問題時,PL/SQL代碼不應(yīng)該忽略,相反應(yīng)該調(diào)整到最佳的結(jié)果.
主站蜘蛛池模板: 国产在线一区二区 | 亚洲精品第一国产综合野 | 在线免费观看黄a | 午夜寂寞影院在线观看 | 亚洲顶级毛片 | 久久国产精品免费一区二区三区 | 国产精品电影在线观看 | 欧美.com| 九九热在线免费视频 | 国内成人免费视频 | 国产精品夜夜春夜夜爽久久电影 | 美女天天操 | 91在线免费观看 | 免费国产一区二区视频 | 久久精彩| 久久精品二区亚洲w码 | 干干干操操操 | 久久精品播放 | 在线观看免费av网 | 激情a| 精品成人免费一区二区在线播放 | 新超碰97| 请别相信他免费喜剧电影在线观看 | 精品国产99 | 精品色| 天堂色综合 | 亚洲欧美日韩精品久久亚洲区 | 久久这里只有精品首页 | 91精品久久久久久久久中文字幕 | 奇米影视在线 | 一级全黄少妇性色生活免费看 | 久久久久久久久久久久久9999 | 亚洲精品久久久久久国产精华液 | 免费久久视频 | 国产91综合 | 黄色免费网站在线看 | 视频在线一区二区 | 亚洲综合色视频在线观看 | 天天干天天操 | 国产片网站 | a精品视频 |