To analyze the PL/SQL code and identifying performance issues using DBMS_PROFILER, we need to first start the profiler using DBMS_PROFILER.START_PROFILER, then we can execute the our pl/sql procedure we want monitored and at last we need to simply call DBMS_PROFILER.STOP_PROFILER to stop the profiler. We do not need to call DBMS_PROFILER.FLUSH_DATA explicitly as DBMS_PROFILER.STOP_PROFILE flush profiler data automatically.
To analyze PL/SQL and identify bottlenecks, we can break the use of DBMS_PROFILER in following steps:
1. Collect Profiler data for PL/SQL Block
2. Identify RUNID using PLSQL_PROFILER_RUNS
3. Identify UNIT_NUMBER using PLSQL_PROFILER_UNITS
4. Identify PL/SQL Line Number which may have performace issue by PLSQL_PROFILER_DATA
5. Get the Line of Code by USER_SOURCE
We have create a procedure "SP_CREATE_CSV" hich creates CSV file, using following example:
- http://nimishgarg.blogspot.in/2011/09/create-csv-file-using-plsql.html
Step 1: Collect Profiler data
C:\>sqlplus scott/tiger
SQL*Plus: Release 11.2.0.3.0 Production on Tue Feb 26 14:21:35 2013
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Release 11.2.0.3.0 - Production
SQL> exec dbms_profiler.start_profiler('Test SP_CREATE_CSV');
PL/SQL procedure successfully completed.
SQL> exec SP_CREATE_CSV;
PL/SQL procedure successfully completed.
SQL> exec dbms_profiler.stop_profiler;
PL/SQL procedure successfully completed.
PL/SQL procedure successfully completed.
Step 2. Identify RUNID using PLSQL_PROFILER_RUNS
SQL> select runid, run_owner, run_date, run_total_time
2 from plsql_profiler_runs
3 where run_comment='Test SP_CREATE_CSV';
RUNID RUN_OWNER RUN_DATE RUN_TOTAL_TIME
---------- -------------------------------- --------- --------------
1 SCOTT 26-FEB-13 2.3313E+10
Step 3. Identify UNIT_NUMBER using PLSQL_PROFILER_UNITS
SQL> select unit_number, unit_timestamp, total_time
2 from plsql_profiler_units
3 where runid=1 and unit_name='SP_CREATE_CSV';
UNIT_NUMBER UNIT_TIME TOTAL_TIME
----------- --------- ----------
3 26-FEB-13 0
Step 4. Identify problematic PL/SQL Line Number by PLSQL_PROFILER_DATA
SQL> select line#, total_occur, total_time, min_time, max_time,
2 round(total_time/total_occur,0) avg_time
3 from plsql_profiler_data
4 where runid=1 and unit_number=3
5 order by avg_time desc;
LINE# TOTAL_OCCUR TOTAL_TIME MIN_TIME MAX_TIME AVG_TIME
---------- ----------- ---------- ---------- ---------- ----------
3 1 113561 372 112488 113561
7 3 206807 96 193721 68936
6 1 19143 19143 19143 19143
17 1 11097 11097 11097 11097
1 1 10643 10643 10643 10643
9 14 14857 640 5963 1061
11 14 11386 673 1891 813
12 14 8631 553 673 617
10 14 6616 412 995 473
13 14 6024 369 496 430
16 1 336 336 336 336
14 14 4273 75 396 305
Now we have all the details required to get bottlenecks of SP_CREATE_CSV. Now we know that line number 3,7 of SP_CREATE_CSV are the top two time consuming statements on an average (basis of single execution). We just need to check what code of lines are they.
Step 5. Get the Line of Code by USER_SOURCE
SQL> column text format a60;
SQL> select line, text from user_source
2 where name='SP_CREATE_CSV'
3 and line in (3,7);
LINE TEXT
---------- ---------------------------------------------------------
3 CURSOR C1 IS SELECT EMPNO, ENAME, SAL, E.DEPTNO, DNAME
FROM EMP E, DEPT D WHERE E.DEPTNO = D.DEPTNO ORDER BY EMPNO;
7 FOR C1_R IN C1
Read Previous: DBMS_PROFILER: Overview and How to Install
Related Links:
- How to Get Execution Plan and Statistics of Query
- Query Optimization Tips for Oracle
- Oracle TKPROF - Simple Steps
- plsql_warnings: Ensure more quality and performance in plsql code using Oracle Compiler
- PLSQL Tuning: Bind Variables and execute immediate
- PLSQL Tuning: Bulk Collect with Dynamic SQL
- Append String to CLOB in Optimized way
- Tune Complete Refresh of Materialized View by atomic_refresh=>false parameter of dbms_mview.refresh
Great and helpful post!
ReplyDeleteThank you
Good info...i would like to know time is calculated as seconds or milli seconds in plsql_profiler_data..
ReplyDeleteIt is Elapsed time in nanoseconds
ReplyDeletegood one
ReplyDeleteOne very small suggestion: change title of blog to Let's Develop in Oracle. You need that apostrophe! :-)
ReplyDeleteAs you say :)
Deletehoo
ReplyDeleteGreat
ReplyDeleteIs there any way to add this profiler in production procedure/function automatically when application runs without manually calling start and stop ?
ReplyDeleteBursa
ReplyDeleteMersin
izmir
Rize
Antep
1CAHJ
Yalova
ReplyDeleteHatay
MuÅŸ
Bursa
Mersin
YMUOS0
https://titandijital.com.tr/
ReplyDeleteçorum parça eşya taşıma
niğde parça eşya taşıma
kastamonu parça eşya taşıma
istanbul parça eşya taşıma
GDKS6
ankara parça eşya taşıma
ReplyDeletetakipçi satın al
antalya rent a car
antalya rent a car
ankara parça eşya taşıma
4CJ
ankara evden eve nakliyat
ReplyDeletemalatya evden eve nakliyat
antep evden eve nakliyat
giresun evden eve nakliyat
kayseri evden eve nakliyat
118RY
58832
ReplyDeleteKütahya Parça Eşya Taşıma
Kırıkkale Evden Eve Nakliyat
Samsun Evden Eve Nakliyat
Batman Evden Eve Nakliyat
Sakarya Lojistik
62D24
ReplyDeleteMaraş Parça Eşya Taşıma
Karaman Şehirler Arası Nakliyat
Bingöl Parça Eşya Taşıma
Ankara Fayans Ustası
Kilis Lojistik
Burdur Şehirler Arası Nakliyat
Antalya Evden Eve Nakliyat
Kars Parça Eşya Taşıma
Tokat Şehirler Arası Nakliyat
FD26A
ReplyDeleteBurdur Şehirler Arası Nakliyat
Yalova Şehir İçi Nakliyat
Samsun Şehirler Arası Nakliyat
Kırklareli Şehir İçi Nakliyat
Mersin Lojistik
Ankara Evden Eve Nakliyat
Amasya Lojistik
Hatay Parça Eşya Taşıma
Antep Evden Eve Nakliyat
F5459
ReplyDeletekonya telefonda görüntülü sohbet
şırnak sesli sohbet sesli chat
adıyaman görüntülü canlı sohbet
istanbul rastgele sohbet siteleri
erzincan görüntülü sohbet uygulamaları ücretsiz
kırklareli kızlarla canlı sohbet
van canlı sohbet odası
artvin sesli sohbet
bayburt sesli sohbet sitesi
7BF74
ReplyDeleteBurdur Rastgele Sohbet Odaları
amasya kadınlarla sohbet
karabük telefonda canlı sohbet
bolu rastgele görüntülü sohbet
Çorum Parasız Sohbet
canli goruntulu sohbet siteleri
bursa mobil sohbet bedava
kayseri görüntülü sohbet siteleri
sinop sohbet chat
E6B2C
ReplyDeletesesli sohbet mobil
mobil sohbet odaları
muğla tamamen ücretsiz sohbet siteleri
sesli sohbet
ardahan telefonda rastgele sohbet
en iyi ücretsiz görüntülü sohbet siteleri
Denizli Telefonda Kızlarla Sohbet
Batman Telefonda Kadınlarla Sohbet
canli goruntulu sohbet siteleri
A86C6
ReplyDeletemetamask
bitbox
galagames
arbitrum
poocoin
ledger live
uniswap
dextools
arbitrum
7300B
ReplyDeleteeigenlayer
poocoin
quickswap
safepal
satoshi
phantom
zkswap
dextools
trezor suite
Nursing jobs in Germany present an exciting avenue for Indian nurses aspiring to thrive in a robust healthcare environment. With a substantial demand for skilled professionals, candidates can access diverse opportunities across hospitals, nursing homes, and specialized clinics. Competitive salaries and extensive benefits packages are typically offered, enhancing the appeal of these roles. While a valid nursing qualification and basic proficiency in the German language are necessary, many employers provide supportive language training programs. The focus on professional development encourages nurses to pursue advanced education and specialization. Moreover, Germany's welcoming culture and high living standards make it an attractive destination for those looking to gain international experience. Embrace this chance to elevate your nursing career while making a significant impact on patient care in Germany.
ReplyDeletehttps://www.dynamichealthstaff.com/nursing-jobs-in-germany-for-indian-nurses