




下載本文檔
版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、Profiling and Tracing PL/SQL CodeObjectivesAfter completing this lesson, you should be able to do the following:Trace PL/SQL program executionProfile PL/SQL applicationsLesson AgendaTracing PL/SQL program executionProfiling PL/SQL applicationsEnable specific subprograms for tracing (optional)Start t
2、racing sessionTracing PL/SQL ExecutionTracing PL/SQL execution provides you with a better understanding of the program execution path, and is possible by using the dbms_trace package.Trace dataTrace dataRun application to be tracedStop tracing sessionTracing PL/SQL ExecutionThe dbms_trace package co
3、ntains:set_plsql_trace (trace_level INTEGER)clear_plsql_traceplsql_trace_versionTracing PL/SQL ExecutionUsing set_plsql_trace, select a trace level to identify how to trace calls, exceptions, SQL, and lines of code.Trace-level constants:trace_all_calls trace_enabled_calls trace_all_sqltrace_enabled_
4、sql trace_all_exceptions trace_enabled_exceptions trace_enabled_linestrace_all_lines trace_stoptrace_pausetrace_resumeTracing PL/SQL: StepsEnable specific program units for trace data collection.Use dbms_trace.set_plsql_trace to identify a trace level.Start tracing by running your PL/SQL code.Use db
5、ms_trace.clear_plsql_trace to stop tracing data.Read and interpret the trace information.12345ALTER PROCEDURE | FUNCTION | PACKAGE subprogram-name COMPILE DEBUG BODY;Step 1: Enable Specific SubprogramsEnable specific subprograms with one of the two methods:Enable a subprogram by compiling it with th
6、e debug option: pile a specific subprogram with the debug option:ALTER SESSION SET PLSQL_DEBUG=true;CREATE OR REPLACE .Steps 2 and 3: Identify a Trace Level and Start TracingSpecify the trace level by using dbms_trace.set_plsql_trace:Execute the code that is to be traced:EXECUTE my_programEXECUTE DB
7、MS_TRACE.SET_PLSQL_TRACE - (tracelevel1 + tracelevel2 .)EXECUTE DBMS_TRACE.CLEAR_PLSQL_TRACEStep 4: Turn Off Tracing Remember to turn tracing off by using the dbms_trace.clear_plsql_trace procedure.Step 5: Examine the Trace InformationExamine the trace information:Call tracing writes out the program
8、 unit type, name, and stack depth.Exception tracing writes out the line number.plsql_trace_runs and plsql_trace_eventsTrace information is written to the following dictionary views:plsql_trace_runs dictionary viewplsql_trace_events dictionary viewRun the tracetab.sql script to create the dictionary
9、views.You need privileges to view the trace information in the dictionary views.PROC_NAME PROC_LINE EVENT_PROC_NAME MENT- - - -P5 1 Procedure CallP4 1 P5 Procedure Call 2 rows selected.plsql_trace_runs and plsql_trace_eventsALTER SESSION SET PLSQL_DEBUG=TRUE;ALTER PROCEDURE P5 COMPILE DEBUG;EXECUTE
10、DBMS_TRACE.SET_PLSQL_TRACE(DBMS_TRACE.trace_all_calls)EXECUTE p5EXECUTE DBMS_TRACE.CLEAR_PLSQL_TRACESELECT proc_name, proc_line, event_proc_name, ment FROM sys.plsql_trace_eventsWHERE event_proc_name = P5OR PROC_NAME = P5;Lesson AgendaTracing PL/SQL program executionProfiling PL/SQL applicationsHier
11、archical Profiling ConceptsDefinition:Used to identify hotspots and performance tuning opportunities in PL/SQL applicationsReports the dynamic execution profile of a PL/SQL program organized by function callsReports SQL and PL/SQL execution times separatelyProvides function level summariesBenefits:P
12、rovides more information than a flat profilerCan be used to understand the structure and control flow of complex programsHierarchical Profiling ConceptsThe PL/SQL hierarchical profiler consists of the:Data collection componentAnalyzer componentUsing the PL/SQL ProfilerBy using the PL/SQL profiler, y
13、ou can find:The number of calls to a functionThe function time, not including descendantsThe subtree time, including descendantsParent-children information for each functionWho were the callers of a given function?What functions were called from a particular function?How much time was spent in funct
14、ion X when called from function Y?How many calls to function X came from function Y?How many times did X call Y?Using the PL/SQL ProfilerSample data for profiling:CREATE OR REPLACE PACKAGE BODY credit_card_pkgIS PROCEDURE update_card_info (p_cust_id NUMBER, p_card_type VARCHAR2, p_card_no VARCHAR2)
15、IS v_card_info typ_cr_card_nst; i INTEGER; BEGIN SELECT credit_cards . END update_card_info; PROCEDURE display_card_info (p_cust_id NUMBER) IS v_card_info typ_cr_card_nst; i INTEGER; BEGIN SELECT credit_cards . END display_card_info; END credit_card_pkg; - package bodyUsing the PL/SQL ProfilerBEGIN-
16、 start profiling DBMS_HPROF.START_PROFILING(PROFILE_DATA, pd_cc_pkg.txt);END;1BEGIN DBMS_HPROF.STOP_PROFILING;END;3DECLARE v_card_info typ_cr_card_nst;BEGIN- run application credit_card_pkg.update_card_info (154, Discover, 123456789);END;2Understanding Raw Profiler DataP#! PL/SQL Timer StartedP#C PL
17、SQL._plsql_vmP#X 3P#C PLSQL._anonymous_blockP#X 1634P#C PLSQL.OE.CREDIT_CARD_PKG:11.UPDATE_CARD_INFO#71749359b90ac246 #24P#X 7P#C PLSQL.OE.CREDIT_CARD_PKG:11.CUST_CARD_INFO#c2ad85321cb9b0ae #4P#X 11P#C SQL.OE.CREDIT_CARD_PKG:11._static_sql_exec_line10 #10P#X 1502P#R.P#C PLSQL._plsql_vmP#X 3P#C PLSQL
18、._anonymous_blockP#X 15P#C PLSQL.SYS.DBMS_HPROF:11.STOP_PROFILING#980980e97e42f8ec #53P#RP#RP#! PL/SQL Timer StoppedUsing the Hierarchical Profiler TablesUpload the raw profiler data into the database tables. Run the dbmshptab.sql script that is located in the /home/rdbms/admin folder to set up the
19、profiler tables.Creates these tables:CONNECT OE- run this only once per schema - under the schema where you want the profiler tables locatedD:appAdministratorproduct11.1.0db_1RDBMSADMINdbmshptab.sqlTableDescriptionDBMSHP_RUNSContains top-level information for each run commandDBMSHP_FUNCTION_INFOCont
20、ains information on each function profiledDBMSHP_PARENT_CHILD_INFOContains parent-child profiler informationUsing DBMS_HPROF.ANALYZEDBMS_HPROF.ANALYZE:Analyzes the raw profiler dataGenerates hierarchical profiler information in the profiler database tablesDefinition:DBMS_HPROF.ANALYZE( location IN V
21、ARCHAR2, filename IN VARCHAR2, summary_mode IN BOOLEAN DEFAULT FALSE, trace IN VARCHAR2 DEFAULT NULL, skip IN PLS_INTEGER DEFAULT 0, collect IN PLS_INTEGER DEFAULT NULL, ment IN VARCHAR2 DEFAULT NULL)RETURN NUMBER;Using DBMS_HPROF.ANALYZE to Write to Hierarchical Profiler TablesUse the DBMS_HPROF.AN
22、ALYZE function to upload the raw profiler results into the database tables.This function returns a unique run identifier for the run. You can use this identifier to look up results corresponding to this run from the hierarchical profiler tables.DECLARE v_runid NUMBER;BEGIN v_runid := DBMS_HPROF.ANAL
23、YZE (LOCATION = PROFILE_DATA, FILENAME = pd_cc_pkg.txt); DBMS_OUTPUT.PUT_LINE(Run ID: | v_runid);END;RUN_ID- 1 Sample Analyzer Output from the DBMSHP_RUNS Table Query the DBMSHP_RUNS table to find top-level information for each run:SELECT runid, run_timestamp, total_elapsed_timeFROM dbmshp_runs WHER
24、E runid = 1; RUNID RUN_TIMESTAMP TOTAL_ELAPSED_TIME - - - 2 12-DEC-07 84000 PM 122650Sample Analyzer Output from the DBMSHP_FUNCTION_INFO Table Query the DBMSHP_FUNCTION_INFO table to find information about each function profiled:SELECT owner, module, type, function line#, namespace, calls
25、, function_elapsed_timeFROM dbmshp_function_infoWHERE runid = 1;OWNER MODULE TYPE LINE# NAMESPACE CALLS TIME- - - - - - - _anonymous_block PLSQL 2 1650 _plsql_vm PLSQL 2 10OE CREDIT_CARD PACKAGE BODY CUST_CARD_INFO PLSQL 1 66 _PKGOE CREDIT_CARD PACKAGE BODY UPDATE_CARD_INFO PLSQL 1 38 _PKGSYS DBMS_HPROF PACKAGE BODY STOP_PROFILING PLSQL 1 0 _PKGOE CREDIT_CARD PACKAGE BODY _static_sql_exec_line10 SQL 1 1502 _PKGOE CREDIT_CARD PACKAGE BODY _static_sql_exec_line41SQL 1 8999 _PKGplshprof: A Simple HTML Report Generatorplshprof is a command-
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 寧夏銀川平原灌區(qū)土壤鹽堿化特征及其驅(qū)動(dòng)因素研究
- 大眾點(diǎn)評(píng)APP用戶持續(xù)使用意愿影響因素研究
- Hamilton的外蘊(yùn)拼擠定理的新證明
- 2025年第六屆全國(guó)國(guó)家版圖知識(shí)競(jìng)賽測(cè)試試題題庫(kù)(中小學(xué)組)及參考答案詳解(典型題)
- 數(shù)控機(jī)床智能化升級(jí)技術(shù)路線圖與效益分析報(bào)告2025
- 2025年工業(yè)互聯(lián)網(wǎng)平臺(tái)IPv6技術(shù)升級(jí)對(duì)設(shè)備聯(lián)網(wǎng)的影響報(bào)告
- 互聯(lián)網(wǎng)金融平臺(tái)合規(guī)整改與金融科技風(fēng)險(xiǎn)防范研究報(bào)告
- 2025年在線教育平臺(tái)學(xué)習(xí)效果跟蹤與用戶滿意度提升策略
- 2025年社區(qū)生鮮電商業(yè)態(tài)創(chuàng)新與數(shù)字化運(yùn)營(yíng)模式解析
- T/DZJN 61-2021基于梯次利用電池的移動(dòng)儲(chǔ)能系統(tǒng)技術(shù)與安全規(guī)范
- 奇妙的剪紙藝術(shù)(欣賞)-完整版課件
- 中醫(yī)學(xué)理論-筋膜學(xué)與人體經(jīng)絡(luò)共120張課件
- 剪力墻結(jié)構(gòu)設(shè)計(jì)實(shí)例講解共74張課件
- 連桿錘鍛模設(shè)計(jì)說(shuō)明書
- 北京市供熱系統(tǒng)節(jié)能技術(shù)改造項(xiàng)目節(jié)能量測(cè)試辦法
- 風(fēng)電項(xiàng)目設(shè)備物資采購(gòu)計(jì)劃
- 核磁共振波譜法之氫譜解析
- 唐詩(shī)三百首word版
- 二次函數(shù)集體備課活動(dòng)記錄(2)
- 硬筆書法考級(jí)專用紙(4—5級(jí))
- 旅游景區(qū)財(cái)務(wù)制度及流程
評(píng)論
0/150
提交評(píng)論