Beruflich Dokumente
Kultur Dokumente
• Database Calls
• Idle and Non-Idle Waits
• Binds
• Analyzing the 10046 SQL Trace with TKPROF
• Making sense of User Response Time
2
Event 10046 SQL Trace
3
Tracing with Event 10046
ALTER SESSION SET EVENTS '10046 TRACE NAME CONTEXT FOREVER, LEVEL 12';
DECLARE
cust_type NUMBER;
over_limit NUMBER;
BEGIN
FOR i IN 1 .. 5
LOOP
select
max(orders_total - credit_limit)
into over_limit
from customer_v v, part
where orders_total > credit_limit
and customer_type = i;
END LOOP;
END;
/
QUIT;
4
Event 10046 SQL Trace sample
=====================
PARSING IN CURSOR #2 len=122 dep=1 uid=119 oct=3 lid=119 tim=1249721241739419 hv=670147313 ad='9820f690' sqlid='6krw4hcmz38rj'
SELECT MAX(ORDERS_TOTAL - CREDIT_LIMIT) FROM CUSTOMER_V V, PART WHERE ORDERS_TOTAL > CREDIT_LIMIT AND CUSTOMER_TYPE = :B1
END OF STMT
BINDS #2:
Bind#0
oacdty=02 mxl=22(22) mxlc=00 mal=00 scl=00 pre=00
oacflg=03 fl2=206001 frm=00 csi=00 siz=24 off=0
kxsbbbfp=b7d92144 bln=22 avl=02 flg=05
value=5
EXEC #2:c=0,e=0,p=0,cr=0,cu=0,mis=0,r=0,dep=1,og=1,plh=1302937547,tim=1249721241739419
FETCH #2:c=189971,e=197994,p=0,cr=3065,cu=0,mis=0,r=1,dep=1,og=1,plh=1302937547,tim=1249721241937413
CLOSE #2:c=0,e=0,dep=1,type=3,tim=1249721241937413
EXEC #5:c=1834721,e=1847934,p=1057,cr=17116,cu=0,mis=0,r=1,dep=0,og=1,plh=0,tim=1249721241937413
WAIT #5: nam='SQL*Net message to client' ela= 3 driver id=1413697536 #bytes=1 p3=0 obj#=92439 tim=1249721241942899
5
Recursive and Non-Recursive SQL
6
Database Calls
7
Recursive SQL in action
=====================
PARSING IN CURSOR #3 len=210 dep=2 uid=0 oct=3 lid=0 tim=122026736875151
select /*+ rule */ bucket_cnt, row_cnt, cache_cnt, null_cnt, timestamp#,
END OF STMT
EXEC #3:c=0,e=18,p=0,cr=0,cu=0,mis=0,r=0,dep=2,og=3,tim=1220267368751515
FETCH #3:c=0,e=23,p=0,cr=4,cu=0,mis=0,r=1,dep=2,og=3,tim=122026736875159
STAT #3 id=1 cnt=7 pid=0 pos=1 obj=255 op='TABLE ACCESS BY INDEX ROWID H
STAT #3 id=2 cnt=7 pid=1 pos=1 obj=257 op='INDEX RANGE SCAN I_HH_OBJ#_IN
EXEC #1:c=4000,e=3607,p=1,cr=29,cu=0,mis=1,r=0,dep=1,og=4,tim=1220267368
FETCH #1:c=1000,e=5188,p=1,cr=2,cu=0,mis=0,r=1,dep=1,og=4,tim=1220267368
=====================
8
Idle and Non-Idle Waits
• SQL • SQL
• Parse • Parse
• Exec • Exec
• Fetch • Fetch
• Fetch • db file sequential read
• SQL • db file sequential read
• SQL*Net message to client
Non-Idle = within a db call • Fetch
Idle = between db calls • SQL*Net message from client
• SQL
9
Recursive and Non-Recursive SQL
SQL depth 0
SQL SQL
depth 1
depth 2
SQL Genealogy represents the
relationship between SQL
SQL
statements within a process
Time
10
Database Calls
SQL depth 0
SQL SQL
depth 1
SQL
EXEC FETCH
Time
11
Database Calls and Waits
SQL depth 0 SQL SQL
SQL depth 1
EXEC FETCH
Time
12
Concepts Summary
• SQL can be classified as:
• Non-Recursive SQL (depth = 0)
• Recursive SQL (depth > 0)
• User SQL (depth 0)
• Internal SQL (depth > 0)
• Most common Database Calls:
• Parse - CBO Produces an Execution Plan
• Execute - DML operations
• Fetch - Queries
• Waits can be classified as:
• Non-Idle Waits (within DB Calls)
• Idle Waits (between DB Calls)
13
<Insert Picture Here>
14
Motivation
15
TKPROF time summary
OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS
16
TKPROF sample for one SQL
SQL ID: 6krw4hcmz38rj
Plan Hash: 1302937547
SELECT MAX(ORDERS_TOTAL - CREDIT_LIMIT)
FROM
CUSTOMER_V V, PART WHERE ORDERS_TOTAL > CREDIT_LIMIT AND CUSTOMER_TYPE = :B1
17
Beyond TKPROF
18
<Insert Picture Here>
Making sense of
User Response Time
19
User Response Time Analysis
Unaccounted-for Time
Idle Wait Time
DB Call ET DB Call ET
User Response Time
Time
20
Response Time
Unaccounted-for
Response Time
Idle Wait Time
Accounted-for
Response Time
21
Database Call Analysis
Unaccounted-for Time
Database Call CPU Time
OS Call ET OS Call ET
Database Call Elapsed Time
Time
22
Database Call Elapsed Time
Unaccounted-for
Elapsed Time
Non-Idle Wait Time
Accounted-for
Elapsed Time
23
Response Time Accounted-for
Elapsed Time
Database Call
Elapsed Time
Unaccounted-for
Elapsed Time
Non-Idle Wait Time
Unaccounted-for
Response Time
Idle Wait Time
Accounted-for
Response Time
24
Response Time
Accounted-for Time
25
Unaccounted-for Time
26
Response Time Aggregation
* *
Database Calls Non-Idle Unaccounted-for
Elapsed Time
CPU Time Wait Time
* *
Database Calls Idle Unaccounted-for
Response Time
Elapsed Time Wait Time
*
Response Time
28
References
29