Professional Documents
Culture Documents
Avaloq | www.avaloq.com
Switzerland, UK, Luxembourg, Germany, France, Singapore, Hong Kong, Philippines, Australia
Performance Is Key
Presenter Sharing Passion for Efficient Development of High-Quality DB Applications
Avaloq: Swiss core banking system vendor
Development started 1993 (Oracle 7), 200 PL/SQL developers
Business logic in 20 M lines of PL/SQL in database
Approach also relevant for small shops with little DB code
100 ms
200 ms
Potential
# Presentations at OOW
Very high
Very few
Usually lower
Few
SQL
Usually lower
Very many
Infrastructure, instance
Usually lower
PL/SQL Profilers
Property
dbms_profiler
dbms_hprof
8.1.5
11gR1
Recording by line
Recording
table
file
Start with dbms_hprof, then use dbms_profiler if reporting on line-level required (e.g.,
unclear where time spent inside subprogram, code coverage reporting)
7
Gathering of Profiles
PL/SQL API
dbms_hprof.start_profiling('PLSHPROF_DIR', 'myprofile.hpf');
/* activity to be profiled */
dbms_hprof.stop_profiling; /* optional, or just terminate session */
Built into SQL Developer, TOAD, PL/SQL Developer, etc
SQL Developer loads
profile into tables and
deletes raw files when
using built-in functionality.
Ideally, turn start / stop with top-level call or on same call stack level
Measure realistically
First vs. following executions
On DB: PL/SQL code loading, SQL parsing, buffer cache
11
12
13
P#V
P#!
...
P#C
P#X
P#R
...
Namespace
Object
Type
Subprogram
Sig hash
Line
15
myprofile_fn.html
myprofile_nsf.html
myprofile_ts.html
myprofile.html
myprofile_nsp.html
PL/SQL or SQL?
18
20
21
22
Time by Module
Very useful if time in some packages split across very many subprograms.
Possible option to estimate tuning potential.
23
24
PARENT
SUBTREE
FUNCTION
DESCENDANTS
K.H.H.CALL_SLEEP
2,800,569
42
2,800,527
K.H.H.CALL_SLEEP
11,812,431
17
11,812,414
K.H.H.CALL_NO_SLEEP
1,762,206
12
1,762,194
Focused report
${ORACLE_BIN}/plshprof -trace '"K"."H"."H.SLEEP"' -skip 1 -collect 1 output second myprofile.hpf
25
"K"."H"."H"
PL/SQL VM
"".""."__plsql_vm"
Anonymous PL/SQL
"".""."__anonymous_block"
Specific SQL
"K"."P"."__dyn_sql_exec_line631"
26
27
28
29
type
classif
cond
9090
[doc.bp.class(9089)=101619]
5075
[rm$spread_deriv.rel_eam(doc) = '0']
3. Join
1. Generate
id
type
module
function
subtree_elapsed_time
deriv#
cond$1
973
(http://www.brendangregg.com/flamegraphs.html)
31
32
Semantics
y-axis: Call stack, x-axis: width proportional to duration, siblings sorted alphabetically
Interactive: Click to zoom / reset zoom, Search
33
34
Call stacks
Samples
(Stack ID, time)
https://developers.google.com/web/tools/chrome-devtools/profile/rendering-tools/js-execution
36
Semantics
y-axis: Call stack (top down)
x-axis: time
38
39
omitted details
max_depth => 2
P#C PLSQL."K"."H"::7."H.CALL_SLEEP"
P#X 2800544
P#R
40
Usage notes
Performance verhead low enough to run on production.
Ensure enough free disk space and not on a critical file system if full. Cannot set
maximum file size.
No need for a fast server. Just compare relative times in PL/SQL (not SQL vs
PL/SQL).
41
References
https://docs.oracle.com/database/121/ADFNS/adfns_profiler.htm#ADFNS023
42
Reporting
plshprof -uga or -pga
dbms_hprof.analyze(..., profile_uga | profile_pga => true)
43
Action items
Profile PL/SQL as part of end-to-end performance analysis.
Integrate gathering and reporting into your developer and
key business user UI.
44
45
Martin Bchi
martin.buechi@avaloq.com
47