国产成人精品久久免费动漫-国产成人精品天堂-国产成人精品区在线观看-国产成人精品日本-a级毛片无码免费真人-a级毛片毛片免费观看久潮喷

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

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

瀏覽:10日期:2023-11-18 17:08:56
Oracle’s DBMS_Profiler:PL/SQL 性能調(diào)整DBMS_PROFILER 包舉例 ;;;;下面是我提供的怎樣使用配置的簡(jiǎn)單例子,運(yùn)行配置文件來(lái)測(cè)試下面例程的性能. 例程用到的自定義腳本緊隨其后.1. 創(chuàng)建過(guò)程. 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腳本(腳本代碼參見(jiàn)下面),傳入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. 評(píng)估執(zhí)行時(shí)間:執(zhí)行eavluate_profiler_results.sql腳本,得到時(shí)間統(tǒng)計(jì)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í)行時(shí)間提高到86毫秒.但是改變if語(yǔ)句,重新執(zhí)行上面的過(guò)程,將會(huì)得到新的結(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í)行時(shí)間從86毫秒減少到8毫秒,多余的時(shí)間是由于內(nèi)置trunc()函數(shù)引起., 這種情境下假如第一個(gè)條件為false,則不會(huì)執(zhí)行trunc()函數(shù).這僅僅是個(gè)簡(jiǎn)單的例子,當(dāng)你測(cè)試的例程越大,你面臨的挑戰(zhàn)更大.這個(gè)配置結(jié)果也證實(shí)了執(zhí)行期間代碼被覆蓋多少行,從而讓我們知道處于性能監(jiān)視中的代碼范圍。 假如任何PL/SQL塊性能出現(xiàn)問(wèn)題,它也能提煉出各種不同情景的正在在執(zhí)行的代碼并檢查配置結(jié)果,從而查明問(wèn)題所在。6. 對(duì)于一個(gè)特定的情景,假如執(zhí)行一段非凡的代碼段,可以得到合理的分析,即使代碼根本一點(diǎn)都不能運(yùn)行。環(huán)境的創(chuàng)建 默認(rèn)安裝或數(shù)據(jù)庫(kù)的創(chuàng)建狀態(tài)下,DBMS_PROFILER包不會(huì)自動(dòng)安裝,請(qǐng)DBA用profload.sql腳本創(chuàng)建它.用一個(gè)權(quán)限較大的或一個(gè)單獨(dú)的用戶,創(chuàng)建存儲(chǔ)統(tǒng)計(jì)信息的表。假如用如SYS用戶創(chuàng)建,則給其它用戶授予DML權(quán)限,并且對(duì)這些表創(chuàng)建一個(gè)共同的簡(jiǎn)寫(xiě)名. 創(chuàng)建表的如下: PLSQL_PROFILER_RUNS表:PL/SQL配置的運(yùn)行細(xì)節(jié). PLSQL_PROFILER_UNITS表:運(yùn)行中每一個(gè)庫(kù)單元的信息. PLSQL_PROFILER_DATA表:所有配置文件運(yùn)行時(shí)的數(shù)據(jù)累積. PLSQL_PROFILER_RUNNUMBER序列提供了RUNID運(yùn)行和解釋配置數(shù)據(jù) ORACLE提供了三個(gè)表來(lái)統(tǒng)計(jì),填充RUNID。有許多第三方的工具可以提供自定義的基于這些數(shù)據(jù)的報(bào)告,ORACLE提供profrep.sql腳本評(píng)估數(shù)據(jù)(在<oracle_home>plsqldemo目錄下),下面的兩個(gè)簡(jiǎn)單腳本就是上面用到的,用來(lái)檢查程序單元的執(zhí)行時(shí)間.執(zhí)行時(shí)間以毫秒存儲(chǔ) -----------------------------------------------------------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是非常強(qiáng)大的工具,其一就是可以識(shí)別PL/SQL的性能問(wèn)題.這個(gè)工具最好用在開(kāi)發(fā)時(shí)期,用來(lái)調(diào)整基于各種應(yīng)用的情景的代碼,它也能用很好的調(diào)整已在使用中的例程并且采取顯而易見(jiàn)的時(shí)間去執(zhí)行。 總之,這個(gè)工具可以給每一行代碼給予性能統(tǒng)計(jì),它可以幫助我們?cè)u(píng)估和調(diào)整到一個(gè)出色的水平,當(dāng)檢查SQL語(yǔ)句的性能問(wèn)題時(shí),PL/SQL代碼不應(yīng)該忽略,相反應(yīng)該調(diào)整到最佳的結(jié)果.
主站蜘蛛池模板: 日韩一级片免费在线观看 | 国产一区二区三区在线观看精品 | 亚洲三级大片 | 国产精品情侣久久婷婷文字 | 久久久久久久久久免费视频 | 一区二区三区影视 | 亚洲日产综合欧美一区二区 | 91精品国产高清久久久久 | 日韩高清成人毛片不卡 | 欧美成人全部视频 | 免费三级网站 | 成人欧美网站免费 | 日日噜噜噜夜夜爽爽狠狠69 | 欧美在线观看成人高清视频 | 久久99久久| 1024香蕉视频在线播放 | 国产精品毛片va一区二区三区 | 久久国产精品免费观看 | 国产日韩一区二区三区在线播放 | 中文字幕乱码中文乱码51精品 | 欧美在线一级va免费观看 | 一本伊大人香蕉高清在线观看 | 久久亚洲国产最新网站 | 手机看片国产免费 | 久久国产精品久久久久久 | 免费看一级做a爰片久久 | 国产精品一级视频 | 欧美日韩亚洲v在线观看 | 亚洲欧美精品网站在线观看 | 综合视频在线 | 日产一区两区三区四区 | 日本视频播放免费线上观看 | 国产精品18久久久久久久久久 | 色aaa| 毛片大全在线观看 | 欧美中文一区 | 欧美激情久久久久久久久 | 久久免费国产视频 | 2021国产精品系列一区二区 | 日韩免费高清一级毛片 | 国内精品不卡一区二区三区 |