04_NEW_features

advertisement
10g New Performance Features
1.
2.
3.
4.
5.
Alerts
Metrics
AWR ( 7 days of history DBA_HIST_ )
Time Model
Wait Classes
6. Misc
Copyright 2006 Kyle Hailey
#.1
Alerts Set
select
metrics_name alert,
warning_operator op,
warning_value warn ,
object_name obj
from
dba_thresholds;
In 10g, alerts are
managed in the
database
ALERT
----------------------------------Average Users Waiting Counts
Concurrency
Blocked User Session Count
CPU Time Per User Call
Logons Per Sec
Session Limit %
Tablespace Space Usage
Tablespace Space Usage
Copyright 2006 Kyle Hailey
OP
WARN
OBJ
---- ------ ------GT
10
GT
GE
GE
GT
GE
GE
0
8000
100
90
85
90
db3
SYSTEM
#.2
Alerts Outstanding
select
reason,
object_type type,
object_name name
from
dba_outstanding_alerts;
REASON
TYPE
NAME
------------------------------------------ ----------- ------Tablespace [PERFSTAT] is [97 percent] full
Copyright 2006 Kyle Hailey
TABLESPACE PERFSTA
#.3
Alerts Setting
DBMS_SERVER_ALERT.SET_THRESHOLD(
METRICS_ID
=> DBMS_SERVER_ALERT.CPU_TIME_PER_CALL,
WARNING_OPERATOR
=> DBMS_SERVER_ALERT.OPERATOR_GE,
dbms_server_alert.set_threshold(
WARNING_VALUE
METRICS_ID
=>
=> '8000',
dbms_server_alert.tablespace_pct_full,
CRITICAL_OPERATOR
WARNING_OPERATOR
=>
=> DBMS_SERVER_ALERT.OPERATOR_GE,
dbms_server_alert.operator_ge,
CRITICAL_VALUE
WARNING_VALUE
=>
=> '10000',
90,
OBSERVATION_PERIOD
CRITICAL_OPERATOR
=>
=> 1,dbms_server_alert.operator_ge,
CONSECUTIVE_OCCURRENCES
=>
CRITICAL_VALUE
=> 2,99,
INSTANCE_NAME
OBSERVATION_PERIOD
=>
=> 'SID',
1,
OBJECT_TYPE
CONSECUTIVE_OCCURRENCES =>
=> DBMS_SERVER_ALERT.OBJECT_TYPE_SERVICE,
1,
OBJECT_NAME
INSTANCE_NAME
=>
=> 'SID')
null,
OBJECT_TYPE
=>
dbms_server_alert.object_type_tablespace,
OBJECT_NAME
=>
'SYSTEM');
http://www.psoug.org/reference/dbms_serv_alert.html
Copyright 2006 Kyle Hailey
#.4
9i
10g Metrics
DBA_HIST_SQLSTAT
v$sqlv$sql
SQL
Waits
V$eventmetric
v$system_eventv$system_event
V$waitclassmetric
V$session_wait
Metrics
v$sysstat
Stats
v$systat
V$session_event
V$sesstat
v$session
v$session
Sessions
V$sessmetric
V$sysmetric
Copyright 2006 Kyle Hailey
#.5
Metrics
What inspired Metrics?
 Alerting
But … metrics make our lives easier
 Old
statistics were cumulative
 Old statistics lacked history
Question:
What is the IO on the system right now?
Copyright 2006 Kyle Hailey
#.6
First Tedious Step
Select value from v$sysstat
where name=‘physical reads’;
VALUE
--------------1,533,787
Not much help …Why? Let see …
Copyright 2006 Kyle Hailey
#.7
This tells you … Nothing
GOOD
BAD
1,533,787
30 minutes
IO’s
30 minutes
time
time
Copyright 2006 Kyle Hailey
#.8
Need to do MATH to find Out
Take value at time A
Take value at time B
Delta = (B-A)
or
Rate = (B-A)/elapsed time
Copyright 2006 Kyle Hailey
#.9
Methods
 Oracle 6 Utlbstat.sql/Utlestat.sql
 Creates
tables, inserts, deletes
 Oracle 8 introduced Statspack
 Improvement,
but needs to be set up and administered
(by guess who)
 Oracle 10 introduces Metrics (and AWR & OEM)
Overkill to run statspack for one or two statistics,
now 10g gives us metric tables
Copyright 2006 Kyle Hailey
#.10
Performance Metric Deltas
Kinds of Metric Tables
1. Metric – current
2. Metric History – last hour
History of Values over last hour
Current Deltas
V$EVENTMETRIC
V$FILEMETRIC
V$SESSMETRIC
V$SERVICEMETRIC
V$SYSMETRIC
V$SYSMETRIC_SUMMARY
V$WAITCLASSMETRIC
V$FILEMETRIC_HISTORY
V$SYSMETRIC_HISTORY
V$SERVICEMETRIC_HISTORY
V$WAITCLASSMETRIC_HISTORY
Copyright 2006 Kyle Hailey
#.11
Metrics
 Calculations
 Intervals
 15
second
 60 second
 10 minutes - file IO
 30 minutes - sql
 Deltas
 Rates


per second
per transaction
 Ratios
 Percentages
Copyright 2006 Kyle Hailey
#.12
Metric Tables
Wait Events


V$EVENTMETRIC (60 secs )
V$WAITCLASSMETRIC (60 secs)
Statistics


V$SESSMETRIC (15 secs Deltas)
V$SYSMETRIC (15 and 60 secs deltas)
Files

V$FILEMETRIC ( 10 minutes)
SQL

DBA_HIST_SQLSTAT
Copyright 2006 Kyle Hailey
#.13
Answer at your fingertips
GOOD
BAD
3 IO/sec
X
1,533,787
513 IO/sec
30 minutes
IO’s
30 minutes
time
time
Copyright 2006 Kyle Hailey
#.14
Now What’s the IO?
Select VALUE , METRIC_UNIT
from v$sysmetric
where metric_name='Physical Reads Per Sec‘;
VALUE METRIC_UNIT
INTSIZE_CSEC
---------- ----------------- -----------654.6736 Reads Per Second
5959
134.9835 Reads Per Second
1515
Avg IO per sec for the last 15 and 60 secs
Copyright 2006 Kyle Hailey
#.15
v$sysmetric
desc v$sysmetric
BEGIN_TIME
END_TIME
INTSIZE_CSEC – interval value in 1/100sec
GROUP_ID
METRIC_ID
METRIC_NAME
VALUE
METRIC_UNIT
Attention: metric_names are different from v$sysstat
Copyright 2006 Kyle Hailey
#.16
v$sysmetric 15 Secs
Per Sec and Per Transaction
Buffer Cache Hit Ratio
Memory Sorts Ratio
Execute Without Parse Ratio
Soft Parse Ratio
Database CPU Time Ratio
Library Cache Hit Ratio
Shared Pool Free %
Txns Per Logon
Per Sec
User Transaction Per Sec
Physical Reads
Physical Writes
Physical Reads Direct
Redo Generated
Logons
User Calls
Logical Reads
Redo Writes
Total Table Scans
Full Index Scans
DB Block Gets
Consistent Read Gets
DB Block Changes
Consistent Read Changes
Executions
Copyright 2006 Kyle Hailey
#.17
v$sysmetric 60 Sec
Buffer Cache Hit Ratio
Memory Sorts Ratio
Redo Allocation Hit Ratio
User Commits Percentage
User Rollbacks Percentage
Cursor Cache Hit Ratio
Rows Per Sort
Execute Without Parse Ratio
Soft Parse Ratio
User Calls Ratio
Global Cache Average CR Get Time
Global Cache Average Current Get Time
Global Cache Blocks Corrupted
Global Cache Blocks Lost
Current Logons Count
Current Open Cursors Count
User Limit %
SQL Service Response Time
Database Wait Time Ratio
Database CPU Time Ratio
Row Cache Hit Ratio
Row Cache Miss Ratio
Library Cache Hit Ratio
Library Cache Miss Ratio
Shared Pool Free %
PGA Cache Hit %
Process Limit %
Session Limit %
Txns Per Logon
Copyright 2006 Kyle Hailey
#.18
v$sysmetric 60 Sec
Per Second and Transaction
Per Sec
User Commits
User Rollbacks
User Transaction
DBWR Checkpoints
Background Checkpoints
Network Traffic Volume
Per Transaction
Response Time
Physical Reads
Physical Writes
Physical Reads Direct
Physical Writes Direct
Physical Reads Direct Lobs
Physical Writes Direct Lobs
Redo Generated
Logons
Open Cursors
User Calls
Recursive Calls
Logical Reads
Redo Writes
Long Table Scans
Total Table Scans
Full Index Scans
Total Index Scans
Total Parse Count
Hard Parse Count
Parse Failure Count
Copyright 2006 Kyle Hailey
Disk Sort
Enqueue Timeouts
Enqueue Waits
Enqueue Deadlocks
Enqueue Requests
DB Block Gets
Consistent Read Gets
DB Block Changes
Consistent Read Changes
CPU Usage
CR Blocks Created
CR Undo Records Applied
User Rollback Undo Records
Applied
Leaf Node Splits
Branch Node Splits
PX downgraded 1 to 25%
PX downgraded 25 to 50%
PX downgraded 50 to 75%
PX downgraded 75 to 99%
.
#.19
v$sessmetric
desc v$sessmetric
BEGIN_TIME
END_TIME
• Only 15 second
Delta
INTSIZE_CSEC
SESSION_ID
SESSION_SERIAL_NUM
CPU
PHYSICAL_READS
PGA_MEMORY
HARD_PARSES
SOFT_PARSES
PHYSICAL_READ_PCT
LOGICAL_READ_PCT
Copyright 2006 Kyle Hailey
#.20
Desc v$eventmetric
SQL> desc v$eventmetric
Name
---------------------------------BEGIN_TIME
END_TIME
INTSIZE_CSEC
EVENT#
EVENT_ID
NUM_SESS_WAITING
TIME_WAITED
WAIT_COUNT
Copyright 2006 Kyle Hailey
Type
-----DATE
DATE
NUMBER
NUMBER
NUMBER
NUMBER
NUMBER
NUMBER
#.21
Historical Metrics
We solved what’s happening now… but
 What if your problem happened 10 minutes ago?
 How do we get History?
 What happened in the past?
Copyright 2006 Kyle Hailey
#.22
Metric History Tables
Last 60 minutes of history, in memory
v$sysstat
physical reads
delta
delta
delta
delta
delta
delta
delta
60 secs
60 secs
60 secs
60 secs
60 secs
60 secs
Copyright 2006 Kyle Hailey
60 secs
#.23
Metric History Tables
Last hour of statistics at your fingertips :
Statistics

V$SYSMETRIC_HISTORY


60 seconds for an hour
3 minutes of 15 second
File IO

3 minutes of 15 second
deltas
60 minutes of 1 minute deltas
V$FILEMETRIC_HISTORY

10 minutes for an hour
Waits

V$WAITCLASSMETRIC_HISTORY

60 seconds for an hour
Copyright 2006 Kyle Hailey
#.24
What was IO 30 minutes ago?
Select
to_char(end_time,'DD-MON-YY HH24:MI'),
VALUE ,
METRIC_UNIT
from
v$sysmetric_history
where
METRIC_NAME = 'Physical Reads Per Sec' and
END_TIME < ( sysdate - (30/(24*60))) and
END_TIME > ( sysdate - (35/(24*60)))
order by end_time;
TO_CHAR(END_TIM
--------------08-JAN-08 11:38
08-JAN-08 11:39
08-JAN-08 11:40
08-JAN-08 11:41
08-JAN-08 11:42
Copyright 2006 Kyle Hailey
VALUE
---------118.65
76.6166667
3.44770153
28.7
19.6166667
METRIC_UNIT
---------------Reads Per Second
Reads Per Second
Reads Per Second
Reads Per Second
Reads Per Second
#.25
V$FILEMETRIC_HISTORY
select
from
BEGIN_TIME,
FILE_ID,
PHYSICAL_READS
V$FILEMETRIC_HISTORY;
BEGIN_TI
FILE_ID PHYSICAL_READS
-------- ---------- -------------04:12:16
1
208
04:12:16
2
600
04:02:18
04:02:18
1
2
600
189
03:52:15
03:52:15
1
2
1922
2082
…
Copyright 2006 Kyle Hailey
Physical Reads
Broken down by
file
#.26
Metric Alerts
If Alerts fire on Metrics, then the deltas are kept in
historical table for 7 days by default
Statistics
DBA_HIST_SYSMETRIC_HISTORY
 DBA_HIST_SESSMETRIC_HISTORY

Waits

WAITCLASSMETRIC_HISTORY
Not to be confused
with the other metric
tables, these only
have values when
alerts fire
File IO

DBA_HIST_FILEMETRIC_HISTORY
Copyright 2006 Kyle Hailey
#.27
Metrics Family of Tables
Stats
Waits
Files
Raw
V$sysstat
v$system_event
v$event_histogram
v$system_wait_class
v$fileio
Now
V$sysmetric
V$SYSMETRIC
V$SYSMETRIC_SUMMARY
V$SESSMETRIC
Session : v$sessmetric
v$eventmetric
v$waitclassmetric
v$filemetric
V$sysmetric_history
V$sysmetric_summary
v$waitclassmetric_history
v$filemetric_history
1 Hour
7 days
Alerts
only
DBA_HIST_SYSMETRIC_HISTORY
DBA_HIST_SESSMETRIC_HISTORY
DBA_HIST_
SYSMETRIC_SUMMARY
DBA_HIST_WAITCLASSMETRIC_HISTORY
DBA_HIST_FILEMETRIC_HISTORY
DBA_HIST_SQLSTAT
DBA_HIST_SYSTEM_EVENT
Copyright 2006 Kyle Hailey
#.28
AWR
Automatic Workload Repository
 Statspack on Steroids
 More efficient than Statspack
 More
in memory
 Less latching
 Keeps stats every hour
 Stores by default the last 7 days
Copyright 2006 Kyle Hailey
#.29
Snapshoting
Done automatically out of the box, but can be run by hand:
BEGIN
DBMS_WORKLOAD_REPOSITORY.CREATE_SNAPSHOT ();
END;
/
dbms_workload_repository.drop_snapshot_range
Copyright 2006 Kyle Hailey
#.30
DBA_HIST
DBA_HIST_DATABASE_INSTANCE
DBA_HIST_SNAPSHOT
- DBA_HIST_SNAP_ERROR
- DBA_HIST_BASELINE
- DBA_HIST_WR_CONTROL ? (work load repository ?)
- DBA_HIST_DATAFILE
DBA_HIST_FILESTATXS – only file number, no name
- DBA_HIST_TEMPFILE
DBA_HIST_TEMPSTATXS – onl;y file number
+DBA_HIST_SQLSTAT group by parent cursor plus DELTAs was (stats$sql_summary)
DBA_HIST_SQLTEXT
+DBA_HIST_SQL_SUMMARY – identify litterals (was stat$sql_statistics)
DBA_HIST_SQL_PLAN
-DBA_HIST_SQLBIND
-DBA_HIST_SQLBIND_META - WRH$_SQL_BIND_METADATA
-DBA_HIST_OPTIMIZER_ENV
-DBA_HIST_EVENT_NAME
DBA_HIST_SYSTEM_EVENT
DBA_HIST_BG_EVENT_SUMMARY – sum of backgrounds
DBA_HIST_WAITSTAT
DBA_HIST_ENQUEUE_STAT
-DBA_HIST_LATCH_NAME
DBA_HIST_LATCH
DBA_HIST_LATCH_CHILDREN
DBA_HIST_LATCH_PARENT
DBA_HIST_LATCH_MISSES_SUMMARY – summed over parent latch
DBA_HIST_LIBRARYCACHE
DBA_HIST_DB_CACHE_ADVICE
DBA_HIST_BUFFER_POOL_STAT
DBA_HIST_ROWCACHE_SUMMARY – summed over rowcache entries
DBA_HIST_SGA
DBA_HIST_SGASTAT
DBA_HIST_PGASTAT
New in 10g
DBA_HIST_RESOURCE_LIMIT
DBA_HIST_SHARED_POOL_ADVICE
?DBA_HIST_SQL_WORKAREA_HSTGRM
DBA_HIST_PGA_TARGET_ADVICE
DBA_HIST_INSTANCE_RECOVERY
DBA_HIST_JAVA_POOL_ADVICE
DBA_HIST_THREAD - logswitches
-DBA_HIST_STAT_NAME
DBA_HIST_SYSSTAT
-DBA_HIST_SYS_TIME_MODEL
-DBA_HIST_OSSTAT_NAME
-DBA_HIST_OSSTAT
DBA_HIST_PARAMETER_NAME
DBA_HIST_PARAMETER
DBA_HIST_UNDOSTAT
DBA_HIST_ROLLSTAT
DBA_HIST_SEG_STAT
DBA_HIST_SEG_STAT_OBJ – object name
-DBA_HIST_METRIC_NAME
-DBA_HIST_SYSMETRIC_HISTORY alert
-DBA_HIST_SYSMETRIC_SUMMARY – max, min, avg standard
deviation
-DBA_HIST_SESSMETRIC_HISTORY alert
-DBA_HIST_FILEMETRIC_HISTORY alert
-DBA_HIST_WAITCLASSMET_HISTORY alert
DBA_HIST_DLM_MISC
-DBA_HIST_RCVRY_FILE_DEST_STAT
-DBA_HIST_RMAN_PERFORMANCE
-DBA_HIST_ACTIVE_SESS_HISTORY – every 10th point from
v$active_session_history
-DBA_HIST_TABLESPACE_STAT
-DBA_HIST_LOG
DBA_HIST_MTTR_TARGET_ADVICE
-DBA_HIST_TBSPC_SPACE_USAGE - ?
Copyright 2006 Kyle Hailey
#.31
Retention and Interval
Defaults:
 Hourly snapshots
 7 days saved
SELECT retention, snap_interval FROM wrm$_wr_control;
RETENTION
SNAP_INTERVAL
----------------- -----------------+00007 00:00:00.0 +00000 01:00:00.0
Minutes
exec dbms_workload_repository.modify_snapshot_settings(14*24*60,30);
RETENTION
SNAP_INTERVAL
----------------- ----------------+00014 00:00:00.0 +00000 00:30:00.0
Copyright 2006 Kyle Hailey
#.32
AWR RPT
@?/rdbms/admin/awrrpt.sql
 Creates Report File
 Similar to STATSPACK report
 More efficient and more data
 HTML or TEXT
SELECT * FROM TABLE(
dbms_workload_repository.awr_report_text(
(select dbid from v$database),
1,
124, -- begin id
125 -- end id ))
Copyright 2006 Kyle Hailey
#.33
AWR Report
1)
2)
3)
4)
5)
6)
7)
8)
9)
10)
General info
Load Profile
Wait Events
OS Stats
Service Stats
Top SQL
SQL Text
Instance Statistic
I/O Stat
Buffer Pool Stats
11) Advisories
1) Buffer pool
2) PGA
3) Shared Pool
4) SGA
5) Streams
6) Java
Copyright 2006 Kyle Hailey
12) Buffer Pool Stats
13) Wait Stats
1) Buffer Busy
2) Enqueues
14) Undo Stats
15) Latch Stats
16) Segment Stats
17) Dictionary Stats
18) Library Cache
19) Memory SGA/PGA
20) Streams
21) Init.ora
#.34
Awr 1-13
Copyright 2006 Kyle Hailey
#.35
AWR 14-26
Copyright 2006 Kyle Hailey
#.36
AWR Diff
SELECT * FROM TABLE(
dbms_workload_repository.awr_diff_report_text(
(select dbid from v$database),
1,
120,
121,
(select dbid from v$database),
1,
122,
123)
);
Also : AWR_DIFF_REPORT_HTML
Copyright 2006 Kyle Hailey
#.37
AWR Diff Report in OEM
NOTE: Package
AWR_DIFF_REPORT_HTML
Is different from OEM
Its just a tabular output
Copyright 2006 Kyle Hailey
#.38
Also, ADDM report by Hand
select dbms_advisor.get_task_report(task_name)
from dba_advisor_tasks
where task_id = (
select max(t.task_id)
from dba_advisor_tasks t,
dba_advisor_log l
where t.task_id = l.task_id and
t.advisor_name = 'ADDM' and
l.status = 'COMPLETED');
Set long 100000
Copyright 2006 Kyle Hailey
#.39
Important AWR Tables
 DBA_HIST_SQLSTAT

SQL deltas
 DBA_HIST_SEG_STAT

Segment deltas
 DBA_HIST_SYSMETRIC_SUMMARY


Stats, max, min, avg
Trending
 DBA_HIST_ACTIVE_SESS_HISTORY

ASH
 DBA_HIST_SYSTEM_EVENT

Waits
dba_hist_sqltext – get sql text from AWR
Copyright 2006 Kyle Hailey
#.40
DBA_HIST_SNAPSHOT
SQL> desc DBA_HIST_SNAPSHOT
Name
------------------SNAP_ID
DBID
INSTANCE_NUMBER
STARTUP_TIME
BEGIN_INTERVAL_TIME
END_INTERVAL_TIME
FLUSH_ELAPSED
SNAP_LEVEL
ERROR_COUNT
Type
----------------------NUMBER
NUMBER
NUMBER
TIMESTAMP(3)
TIMESTAMP(3)
TIMESTAMP(3)
INTERVAL DAY(5) TO SECOND(1)
NUMBER
NUMBER
Copyright 2006 Kyle Hailey
#.41
DBA_HIST_SQLSTAT
SNAP_ID
DBID
INSTANCE_NUMBER
SQL_ID
PLAN_HASH_VALUE
OPTIMIZER_COST
OPTIMIZER_MODE
OPTIMIZER_ENV_HASH_VALUE
SHARABLE_MEM
LOADED_VERSIONS
VERSION_COUNT
MODULE
ACTION
SQL_PROFILE
FORCE_MATCHING_SIGNATURE
PARSING_SCHEMA_ID
PARSING_SCHEMA_NAME
BIND_DATA
FETCHES_DELTA
END_OF_FETCH_COUNT_DELTA
SORTS_DELTA
EXECUTIONS_DELTA
PX_SERVERS_EXECS_DELTA
LOADS_DELTA
INVALIDATIONS_DELTA
PARSE_CALLS_DELTA
DISK_READS_DELTA
BUFFER_GETS_DELTA
ROWS_PROCESSED_DELTA
CPU_TIME_DELTA
ELAPSED_TIME_DELTA
IOWAIT_DELTA
CLWAIT_DELTA
APWAIT_DELTA
CCWAIT_DELTA
DIRECT_WRITES_DELTA
PLSEXEC_TIME_DELTA
JAVEXEC_TIME_DELTA
Copyright 2006 Kyle Hailey
#.42
DBA_HIST_SEG_STAT
Gets reset every DB bounce
SQL> desc DBA_HIST_SEG_STAT
PHYSICAL_WRITES_TOTAL
Name
-------------------------------
PHYSICAL_WRITES_DELTA
SNAP_ID
PHYSICAL_READS_DIRECT_TOTAL
DBID
PHYSICAL_READS_DIRECT_DELTA
INSTANCE_NUMBER
PHYSICAL_WRITES_DIRECT_TOTAL
TS#
PHYSICAL_WRITES_DIRECT_DELTA
OBJ#
ITL_WAITS_TOTAL
DATAOBJ#
ITL_WAITS_DELTA
LOGICAL_READS_TOTAL
ROW_LOCK_WAITS_TOTAL
LOGICAL_READS_DELTA
ROW_LOCK_WAITS_DELTA
BUFFER_BUSY_WAITS_TOTAL
SPACE_USED_TOTAL
BUFFER_BUSY_WAITS_DELTA
SPACE_USED_DELTA
DB_BLOCK_CHANGES_TOTAL
SPACE_ALLOCATED_TOTAL
DB_BLOCK_CHANGES_DELTA
SPACE_ALLOCATED_DELTA
PHYSICAL_READS_TOTAL
TABLE_SCANS_TOTAL
PHYSICAL_READS_DELTA
TABLE_SCANS_DELTA
Copyright 2006 Kyle Hailey
#.43
DBA_HIST_SYSTEM_EVENT
SQL> desc DBA_HIST_SYSTEM_EVENT
Name
Type
---------------------------------SNAP_ID
NUMBER
DBID
NUMBER
INSTANCE_NUMBER
NUMBER
EVENT_ID
NUMBER
EVENT_NAME
VARCHAR2(64)
WAIT_CLASS_ID
NUMBER
WAIT_CLASS
VARCHAR2(64)
TOTAL_WAITS
NUMBER
TOTAL_TIMEOUTS
NUMBER
TIME_WAITED_MICRO
NUMBER
Cumulative Values – can use LAG function
Copyright 2006 Kyle Hailey
#.44
Average Wait Times
select
btime,
(time_ms_end-time_ms_beg)/nullif(count_end-count_beg,0) avg_ms
from (
select
to_char(s.BEGIN_INTERVAL_TIME,'DD-MON-YY HH24:MI') btime,
total_waits count_end,
time_waited_micro/1000 time_ms_end,
Lag (e.time_waited_micro/1000)
OVER( PARTITION BY e.event_name ORDER BY s.snap_id) time_ms_beg,
Lag (e.total_waits)
OVER( PARTITION BY e.event_name ORDER BY s.snap_id) count_beg
from
DBA_HIST_SYSTEM_EVENT e,
DBA_HIST_SNAPSHOT s
where
BTIME
AVG_MS
------------------------------s.snap_id=e.snap_id
and e.event_name= '&1'
08-JAN-08 01:00
1.017
order by begin_interval_time
08-JAN-08 02:00
.720
)
08-JAN-08 03:00
.621
order by btime;
08-JAN-08 04:00
08-JAN-08 05:00
08-JAN-08 06:00
Copyright 2006 Kyle Hailey
1.747
1.046
1.444
#.45
ASH RPT
 @?/rdbms/admin/ashrpt
 Detailed report on top SQL, Sessions, Objects etc
 Run over SQL*Net with
select output
from table(dbms_workload_repository.ash_report_text(
(select dbid from v$database),
1,
sysdate – 2/24,
sysdate – 1/24,
0)) ;
 Also ASH_REPORT_HTML
Copyright 2006 Kyle Hailey
#.46
ASH RPT
1) General info
2) Top User Events ***
3) Top Background Events
4) Top Event P1/P2/P3 Values
5) Top Service/Module
6) Top Client IDs
7) Top SQL Command Types
8) Top SQL Statements ***
9) Top SQL using literals
10) Top Sessions ***
11) Top Blocking Sessions
12) Top Sessions running PQs
13) Top DB Objects
14) Top DB Files
15) Top Latches
16) Activity Over Time ***
Copyright 2006 Kyle Hailey
#.47
ASH RPT HTML
Copyright 2006 Kyle Hailey
#.48
Time Model
New concept
• DB Time
Total time for all database calls
• cpu time
SQL
• wait time
Time Model
Wait
Metrics
Stats
Sessions
Copyright 2006 Kyle Hailey
#.49
Time Model areas
 Total Time
 CPU
 Updated
every 5 seconds
 Elapsed Time
 SQL execution
 Plsql execution (sql execute subtracted out)
 Java execution
 Connection time
 Probably
the most important as it points out problems with
too many logons/sec
Copyright 2006 Kyle Hailey
#.50
Time Model Components
1) background elapsed time
2) background cpu time
1) DB time
2) DB CPU
2) connection management call elapsed time
2) sequence load elapsed time
2) sql execute elapsed time
2) parse time elapsed
3) hard parse elapsed time
4) hard parse (sharing criteria) elapsed time
5) hard parse (bind mismatch) elapsed time
3) failed parse elapsed time
4) failed parse (out of shared memory) elapsed time
2) PL/SQL execution elapsed time
2) inbound PL/SQL rpc elapsed time
2) PL/SQL compilation elapsed time
2) Java execution elapsed time
Copyright 2006 Kyle Hailey
#.51
Total Time
DB CPU
Time
DB Wait
DB CPU
~ DB
Wait
Total
Database
Time
Time
Time Time
Parse
Elapsed
Time
Copyright 2006 Kyle Hailey
#.52
Hard Parse Bind Mismatch
Parse
time
elapsed
hard
parse
hard (sharing
parse criteria)
elapse elapsed
d time
time
Copyright 2006 Kyle Hailey
hard
parse
(bind
mismat
ch)
elapsed
time
#.53
Time Model Tables
Current cumulative values
 V$SYS_TIME_MODEL
 V$SESS_TIME_MODEL
AWR Snapshots of cumulative values
 DBA_HIST_SYS_TIME_MODEL
Tables show cumulative values. To find deltas, then need
to run AWR report (no time model metric tables  )
Copyright 2006 Kyle Hailey
#.54
Wait Classes
Administrative (39)





switch logfile
rebuild index
Application (11)


enqueues
sqlnet break/reset
Cluster (113)
Commit (1)

Log file Sync
Concurrency (12)



Latches: cbc, lbc,
Lib cache locks
Buffer busy wait
Configuration (20)
log file size
Enqueues: ST, HW, ITL
Latch: redo copy,shared pool
Idle (56)
Network (25)
System I/O (19)
Scheduler (6)
User I/O (12)
Other (485)
Copyright 2006 Kyle Hailey
#.55
Wait Class Tables
v$system_wait_class
 cumulative
v$waitclassmetric
 Current
rates
v$waitclassmetric_history
 Hour
of rates (60 second intervals)
Copyright 2006 Kyle Hailey
#.56
Waits Metrics
Cumulative
Current deltas
Last Hour
v$waitclassmetric
v$waitclassmetric_history
BEGIN_TIME
BEGIN_TIME
END_TIME
END_TIME
INTSIZE_CSEC
INTSIZE_CSEC
WAIT_CLASS_ID
WAIT_CLASS_ID
WAIT_CLASS#
WAIT_CLASS#
NUM_SESS_WAITING
NUM_SESS_WAITING
TIME_WAITED
TIME_WAITED
WAIT_COUNT
WAIT_COUNT
Last 7 days
Wait Classes
v$system_wait_class
WAIT_CLASS_ID
WAIT_CLASS#
WAIT_CLASS
TOTAL_WAITS
TIME_WAITED
v$event_name
EVENT#
dba_hist_
waitclassmetric_history
Only gets populated with alerts
EVENT_ID
NAME
PARAMETER1
PARAMETER2
PARAMETER3
WAIT_CLASS_ID
WAIT_CLASS#
WAIT_CLASS
Wait Events
v$system_event
EVENT
TOTAL_WAITS
TOTAL_TIMEOUTS
TIME_WAITED
AVERAGE_WAIT
TIME_WAITED_MICRO
EVENT_ID
v$eventmetric
BEGIN_TIME
END_TIME
INTSIZE_CSEC
EVENT_ID
NUM_SESS_WAITING
TIME_WAITED
WAIT_COUNT
dba_hist_system_event
(Cumulative)
No in memory history
Copyright 2006 Kyle Hailey
#.57
Miscellaneous
 V$sqlstats
 Field naming conventions
 Wait Improvements
 Wait
histograms
 Waits in v$session and v$sql
 Waits show the blocker
 Wait history of last 10 waits
 Services
 Client Id
Copyright 2006 Kyle Hailey
#.58
v$sqlstats
 More efficient than v$sql or v$sqlarea
 Uses less CPU
 Faster
 Skips many of the latch gets that v$sql does
 Uses Mutexes instead of some latches
Copyright 2006 Kyle Hailey
#.59
Event and Stat Fields Names
 Names
Event
 Statistic
 Waitclass

SQL
SQL_ID new hash
HASH_VALUE still there
 Ids
Event#
 Statistic#
 Waitclass#

 Name Hash
Event_id
 Statistic_id
 Waitclass_id

Copyright 2006 Kyle Hailey
#.60
Wait Histograms
V$event_histogram
 1ms to 1 hour buckets
 23 buckets
 < 1 ms, < 2 ms, < 4 ms, < 8 ms, ..., < 2^22 ms
Copyright 2006 Kyle Hailey
#.61
Waits in v$session
 V$session exposes all the fields from v$session_wait
SEQ#
EVENT#
EVENT
P1TEXT
P1
P1RAW
P2TEXT
P2
P2RAW
P3TEXT
P3
P3RAW
WAIT_CLASS_ID
WAIT_CLASS#
WAIT_CLASS
WAIT_TIME
SECONDS_IN_WAIT
STATE
NUMBER
NUMBER
VARCHAR2(64)
VARCHAR2(64)
NUMBER
RAW(4)
VARCHAR2(64)
NUMBER
RAW(4)
VARCHAR2(64)
NUMBER
RAW(4)
NUMBER
NUMBER
VARCHAR2(64)
NUMBER
NUMBER
VARCHAR2(19)
Copyright 2006 Kyle Hailey
#.62
Waits in V$SQL













SQL_FULLTEXT
SQL_ID
FETCHES
END_OF_FETCH_COUNT
DIRECT_WRITES
CONCURRENCY_WAIT_TIME
APPLICATION_WAIT_TIME
CLUSTER_WAIT_TIME
USER_IO_WAIT_TIME
PLSQL_EXEC_TIME
JAVA_EXEC_TIME
CPU_TIME
ELAPSED_TIME
Copyright 2006 Kyle Hailey
#.63
Waits show Blocking Session
V$session. BLOCKING_SESSION -> can
build a wait tree:
Copyright 2006 Kyle Hailey
#.64
Services
 Services is a new way to measure resource usage
and statistics. A session is associated with a
services when the session connects to the
database via the listener.
 DBMS_SERVICE.CREATE_SERVICE
Copyright 2006 Kyle Hailey
#.65
Setting up Services
jdbc:oracle:thin:@//server:1521/SERVICE_NAME
dbms_service.CREATE_SERVICE('ora10a',‘A');
dbms_service.START_SERVICE ('ora10a');
-- dbms_service.STOP_SERVICE ('ora10a');
-- dbms_service.DELETE_SERVICE('ora10a');
tnsA =
tnsnames.ora
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)
Sqlplus
(HOST = kylehpd)(PORT = 1521)) )
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = A)
) )
Name
tracked
in OEM
un/pw@tnsA
lsnrctl services
Service "A" has 1 instance(s).
Instance "v10g", status READY, has 1 handler(s) for this service...
Handler(s):
"DEDICATED" established:0 refused:0 state:ready
Copyright 2006 Kyle Hailey
#.66
Services in OEM
Enable Trace
By Service
View doesn’t work
Copyright 2006 Kyle Hailey
#.67
Client Id
 Setting Client ID
dbms_session.set_identifier(client_id)
 Enabling trace for a client ID
dbms_monitor.client_id_trace_enable
(client_id, TRUE, FALSE)
 Enabling statistics aggregation by client id
dbms_monitor.client_id_stat_enable(client_id)
 Script to Extract Client Trace
Trcsess output=<name> client_id=<name> *
Copyright 2006 Kyle Hailey
#.68
Session Dedicated
Scott
John
Sue
Randy
Mike
Oracle
Sessions
S1
S2
S3
S4
S4
S5
Mary
Tim
S6
Oracle Database Host
Copyright 2006 Kyle Hailey
#.69
Session Dedicated trace
Scott
John
Sue
Randy
Mike
Mary
Tim
SQL_TRACE=TRUE
Oracle
Sessions
S1
S2
S3
S4
S4
S5
S6
Oracle Database Host
Copyright 2006 Kyle Hailey
#.70
Session Pooling trace
Scott
John
Sue
Randy
Mike
Mary
Tim
APP
Server
1
S1, sql_trace=true
Oracle
Sessions
S1
S2
S3
S4
S4
S5
S6
S7
Oracle Database Host
Copyright 2006 Kyle Hailey
#.71
Session Pooling
Scott
John
Sue
Randy
Mike
Set client_id =
SCOTT
Mary
Tim
dbms_monitor.client_id_trace_enable
TRUE, FALSE);
waits, binds
APP (client_id,
Server
1
Oracle
Sessions
S1
S2
S3
S4
S4
S5
S6
S7
Oracle Database Host
Copyright 2006 Kyle Hailey
#.72
DB_FILE_MULTI_BLOCK_READ_COUNT
 Auto tuned in 10gR2
 Recommended to leave unset in init.ora, ex, when unset on my PC



db_file_multiblock_read_count
_db_file_exec_read_count
_db_file_optimizer_read_count
55
55 (IO reads)
8 (optimization)
 When running
Dbms_stats.gather_system_stats(gathering_mode => ‘interval’
interval
=> 30 )
db_file_multiblock_read_count is ignored

 Alter system reset db_file_multiblock_read_count scope=spfile sid=‘*’;
Troubleshooting Oracle Performance
Christian Antognini
Copyright 2006 Kyle Hailey
#.73
UNDO Retention Auto Tuned
 Oracle10G records the times of the longest-running queries
and the amount of undo generated to automatically tune the
UNDO_RETENTION parameter.
 If Autoextend on then undo retention set slightly longer than
the longest running query
 If autoextend off then depends on free space available
 Bug 5387030 – undo retention miscalculated and UNDO can
grow, fixed 10.2.0.4
10.2.0.3 or below can set
 alter system set "_smu_debug_mode" = 33554432

Copyright 2006 Kyle Hailey
#.74
SQL Trace Improvement
 dbms_monitor
New 10g
dbms_monitor.session_trace_enable(session_id => 127,
serial_num => 29,
waits => TRUE,
binds => FALSE)
10gR2 v$session columns
sql_trace
sql_trace_waits
sql_trace_binds
are set when the procedure
session_trace_enable is used and at least one SQL statement has been executed by the
sessionvtraced
Instead of
alter session set events ‘10046 trace name context forever, level 12';
Copyright 2006 Kyle Hailey
#.75
Q1
An ASH report can be run on data covering what time
periods (by default)
a. any 60 seconds in the past week
b. any hour period in the past day
c. any day in the past week
d. any 60 second period in the past hour
answers
all the above
Copyright 2006 Kyle Hailey
#.76
Q2
AWR ( automatic workload repository ) reports on data
covering
what time periods (by default)
a. any 60 seconds in the past week
b. any hour period in the past day
c. any day in the past week
d. any 60 second period in the past hour
answers
b and c - AWR only takes data every hour for a week
by default
Copyright 2006 Kyle Hailey
#.77
Q3
Connecting to Oracle is a CPU intensive operation. A high
logon rate
may indicate an application design issue that unnecessarily
burns CPU.
What performance table(s) indicates the time spent
connecting to the database ?
b - only
a. v$active_session_history
others
b. v$sys_time_model
a,c,d - don't report
c. v$waitclassmetric
connection time or connect
CPU usage
d. v$sysstat
Copyright 2006 Kyle Hailey
#.78
Q4
What is the least resource consuming view for getting the
number
of executions of an sql statement
a. v$sqllite
b - new in 10g, less latch usage than the other
tables
b. v$sqlstats
others
c. v$sql
a doesn't exit
d. v$sqlarea
c reading uses many of the latches as users
executing sql
d the worst, like v$sql, but also does an
expensive group by
Copyright 2006 Kyle Hailey
#.79
Q5
How can you immediately find the top CPU consuming
session in the past 15 seconds
a. v$sessmetric
answer
b. v$active_session_history
a, b
c. v$sesstat
others:
d. v$top_sessions
c - only has cumulative data, need to take
deltas of values to see what is happening
d - doesn't exist
Copyright 2006 Kyle Hailey
#.80
Q6
What script runs 16 different queries against
v$active_session_history to
produce a detailed report over any time interval in the AWR
repository
answer
a. ?/rdbms/admin/spreport.sql
c
b. ?/rdbms/admin/awrrpt.sql
other
c. ?/rdbms/admin/ashrpt.sql
a and b don't use ASH
d. ?/rdbms/admin/ashreport.sql
d doesn't exit
Copyright 2006 Kyle Hailey
#.81
Q7
In 10g, it is recommended to set
db_file_multiblock_read_count to
answer
a. unset
b. 8
c. 16
d. 32
e. 128
a. Oracle will set it automatically to the optimal
value
(this won't affect SQL optimization as Oracle
will calculate
sql optimization with
_db_file_optimizer_read_count
Copyright 2006 Kyle Hailey
)
#.82
Q8
Oracle can track different applications using the "services'
identifier.
After the service identifier gets created and started, how
does the
services identifier get set for a connection.
a. call to dbms_services
b. via the tnsnames.ora connection
c. in the init.ora
d. via a middle tier command
answer
b
Copyright 2006 Kyle Hailey
#.83
Q9
The identifier "client_id" allows a DBA to monitor what
special situation:
a. track different applications resource usage on a database
b. track application users in session pools
c. track dedicated sessions
d. is the same as the database "username"
answer
b - set up specifically to track application users
that connect without
a dedicated connection vi a session pool
Copyright 2006 Kyle Hailey
#.84
Download