Download presentation
Presentation is loading. Please wait.
Published byLaureen Robinson Modified over 9 years ago
1
3 Copyright © 2006, Oracle. All rights reserved. Statistics and Wait Events
2
3-2 Copyright © 2006, Oracle. All rights reserved. Objectives After completing this lesson, you should be able to do the following: Identify dynamic performance views useful in tuning Identify the key tuning components of the alert log file Identify the key tuning components of user trace files Use dynamic performance views to view statistics and wait events
3
3-3 Copyright © 2006, Oracle. All rights reserved. Performance Tuning Data Type of data gathered: Cumulative statistics: –Wait events with time information –Time model Metrics: Statistic rates Sampled statistics: Active session history –Statistics by session –Statistics by SQL –Statistics by service –Other dimensions
4
3-4 Copyright © 2006, Oracle. All rights reserved. Performance Tuning Tools Tools that are available: Basic: –Enterprise Manager pages –Alert log –Trace files –Dynamic performance views and tables Add-in: –Statspack Options: –Diagnostics pack –Tuning pack
5
3-5 Copyright © 2006, Oracle. All rights reserved. Accessing the Database Home Page http://host name:1158/em
6
3-6 Copyright © 2006, Oracle. All rights reserved. EM Performance Pages
7
3-7 Copyright © 2006, Oracle. All rights reserved.
8
3-8 Copyright © 2006, Oracle. All rights reserved. Viewing the Alert Log Database Home page > Related Links region > Alert Log Content
9
3-9 Copyright © 2006, Oracle. All rights reserved. Using Alert Log Information to Aid in Tuning The alert log file contains the following information that can be used to aid in tuning the database: Incomplete checkpoints Time to perform archiving Instance recovery start and complete times Deadlock and timeout errors Checkpoint start and end times
10
3-10 Copyright © 2006, Oracle. All rights reserved.
11
3-11 Copyright © 2006, Oracle. All rights reserved. User Trace Files Server-process tracing can be enabled or disabled at the session or instance level.(sql_trace=true) A user trace file contains statistics for traced SQL statements in that session. User trace files are created on a per server process basis. User trace files can also be created by: –Performing a – ALTER DATABASE BACKUP CONTROL FILE TO TRACE –Process errors
12
3-12 Copyright © 2006, Oracle. All rights reserved. Background Process Trace Files The Oracle database server dumps information about errors detected by any background process into trace files. Oracle Support uses these trace files to diagnose and troubleshoot. These files do not usually contain tuning information. Ora_processname_PID.trc / bdump
13
3-13 Copyright © 2006, Oracle. All rights reserved. Dynamic Performance Views Dynamic performance views provide access to information about changing states and conditions in the instance. Session data Wait events Memory allocations Running SQL UNDO usage Open cursors Redo log usage And so on Oracle instance
14
3-14 Copyright © 2006, Oracle. All rights reserved. Dynamic Performance Views: Usage Examples SQL> SELECT sql_text, executions 2 FROM v$sqlstats 3 WHERE cpu_time > 200000; SQL> SELECT * FROM v$session 2 WHERE machine = 'EDRSR9P1' and 3 logon_time > SYSDATE - 1; SQL> SELECT sid, ctime 2 FROM v$lock WHERE block > 0; a b c
15
3-15 Copyright © 2006, Oracle. All rights reserved. Dynamic Performance Views: Considerations These views are owned by SYS. Different views are available at different times: –The instance has been started. –The database is mounted. –The database is open. You can query V$FIXED_TABLE to see all the view names. These views are often referred to as “v-dollar views.” Read consistency is not guaranteed on these views because the data is dynamic.
16
3-16 Copyright © 2006, Oracle. All rights reserved. Statistic Levels STATISTICS_LEVEL BASIC TYPICALALL Recommended default value Additional statistics for manual SQL diagnostics Disable all self-tuning capabilities V$STATISTICS_LEVEL
17
3-17 Copyright © 2006, Oracle. All rights reserved.
18
3-18 Copyright © 2006, Oracle. All rights reserved. Statistics and Wait Events Statistics Wait events Reports Dynamic performance views
19
3-19 Copyright © 2006, Oracle. All rights reserved. System Statistic Classes Cache Debug RAC SQL Redo User Enqueue OS V$SYSSTAT V$SESSTATV$STATNAME System statistic classes
20
3-20 Copyright © 2006, Oracle. All rights reserved. Displaying Systemwide Statistics V$SYSSTAT STATISTIC# NAME CLASS VALUE V$SGASTAT POOL NAME BYTES V$EVENT_NAME EVENT NUMBER NAME PARAMETER1 PARAMETER2 PARAMETER3 V$SYSTEM_EVENT EVENT TOTAL_WAITS TOTAL_TIMEOUTS TIME_WAITED AVERAGE_WAIT
21
3-21 Copyright © 2006, Oracle. All rights reserved.
22
3-22 Copyright © 2006, Oracle. All rights reserved. Displaying Session-Related Statistics V$STATNAME STATISTIC# NAME CLASS V$SESSTAT SID STATISTIC# VALUE V$SESSION_WAIT SID SEQ# EVENT P1/2/3 P1/2/3 TEXT P1/2/3 RAW WAIT TIME SECONDS_IN_WAIT STATE V$SESSION SID SERIAL# USERNAME OSUSER V$SESSION_EVENT SID EVENT TOTAL_WAITS TOTAL_TIMEOUTS TIME_WAITED AVERAGE_WAIT MAX_WAIT V$EVENT_NAME EVENT# NAME PARAMETER1 PARAMETER2 PARAMETER3
23
3-23 Copyright © 2006, Oracle. All rights reserved.
24
3-24 Copyright © 2006, Oracle. All rights reserved. Displaying Service-Related Statistics V$SERVICE_STATS SERVICE_NAME_HASH SERVICE_NAME STAT_ID STAT_NAME VALUE V$SESSION_WAIT_CLASS SERVICE_NAME SERVICE_NAME_HASH WAIT_CLASS_ID WAIT_CLASS# WAIT_CLASS TOTAL_WAITS TIME_WAITED V$SERVICES SERVICE_ID NAME NAME_HASH NETWORK_NAME CREATION_DATE V$SERVICE_EVENT SERVICE_NAME SERVICE_NAME_HASH EVENT EVENT_ID TOTAL_WAITS TOTAL_TIMEOUTS TIME_WAITED AVERAGE_WAIT MAX_WAIT TIME_WAITED_MICRO
25
3-25 Copyright © 2006, Oracle. All rights reserved.
26
3-26 Copyright © 2006, Oracle. All rights reserved. Wait Events A collection of wait events provides information about the sessions that had to wait or must wait for different reasons. These events are listed in the V$EVENT_NAME view, which has the following columns: – EVENT# – NAME – PARAMETER1 – PARAMETER2 – PARAMETER3
27
3-27 Copyright © 2006, Oracle. All rights reserved. Commonly Observed Wait Events Over-commit, I/OLog file sync Log buffer I/OLog buffer space LatchesLibrary cache waits Locks Enqueue waits (enq:) I/O, SQL TuningDb file scattered read, Db file sequential read Buffer cache, DBWR, I/OFree buffer waits Buffer cache, DBWRBuffer busy waits AreaWait Event
28
3-28 Copyright © 2006, Oracle. All rights reserved. Wait Classes Scheduler Cluster Configuration Commit Application Administrative Network User I/O Concurrency System I/O Other Idle Background processes I/O Foreground processes I/O DBA commands Should be rare Inadequate database/ instance configuration Resource manager RAC resources User application code Inactive sessions Network messaging log file sync Internal database resources V$SESSION_WAIT_CLASS V$SERVICE_WAIT_CLASS V$SYSTEM_WAIT_CLASS V$EVENT_NAME Wait classes
29
3-29 Copyright © 2006, Oracle. All rights reserved.
30
3-30 Copyright © 2006, Oracle. All rights reserved. Using the V$EVENT_NAME View NAME PARAMETER1 PARAMETER2 PARAMETER3 ------------------------------- ---------- ---------- ---------- PL/SQL lock timer duration alter system set mts_dispatcher waited buffer busy waits file# block# id library cache pin handle addr pin address 0*mode+name log buffer space log file switch (checkpoint incomplete) transaction undo seg# wrap# count... 286 rows selected. SQL> SELECT name, parameter1, parameter2, parameter3 2 FROM v$event_name;
31
3-31 Copyright © 2006, Oracle. All rights reserved. Wait Event Statistics These views hold session-level wait event statistics: V$SESSION_EVENT : Session waits by event for each session that had to wait V$SESSION_WAIT : Session waits by event for current active sessions that are waiting V$SYSTEM_EVENT : Total waits for an event, all sessions together
32
3-32 Copyright © 2006, Oracle. All rights reserved. Using the V$SESSION_EVENT View SID EVENT TOTAL_WAITS AVERAGE_WAIT ---- ---------------------------- ----------- ------------ 10 buffer busy waits 12 5 10 db file sequential read 129 0 10 file open 1 0 10 SQL*Net message to client 77 0 10 SQL*Net more data to client 2 0 10 SQL*Net message from client 76 0 SQL> SELECT sid, event, total_waits,average_wait 2 FROM v$session_event 3 WHERE sid=10;
33
3-33 Copyright © 2006, Oracle. All rights reserved. Using the V$SESSION_WAIT View SID SEQ#EVENTWAITSTATE TIME ---- ------ -------------------------------- ------- 11284pmon timer0WAITING 21697rdbms ipc message0WAITING 3183rdbms ipc message0WAITING 44688rdbms ipc message0WAITING 5114smon timer0WAITING 614SQL*Net message from client-1WAITED SHORT TIME SQL> SELECT sid, seq#, event, wait_time, state 2 FROM v$session_wait;
34
3-34 Copyright © 2006, Oracle. All rights reserved.
35
3-35 Copyright © 2006, Oracle. All rights reserved. Using the V$SYSTEM_EVENT View EVENTTOTAL_TOTAL_TIME_AVERAGE_ WAITSTIMEOUTSWAITEDWAIT ----------------------------------------------- latch free5551 pmon timer932535254430272.993562 process startup382.66666667 buffer busy waits12055... 34 rows selected. SQL> SELECT event, total_waits, total_timeouts, 2 time_waited, average_wait 3 FROM v$system_event;
36
3-36 Copyright © 2006, Oracle. All rights reserved. Precision of System Statistics Views that include microsecond timings: – V$SESSION_WAIT, V$SYSTEM_EVENT, V$SERVICE_EVENT, V$SESSION_EVENT ( TIME_WAITED_MICRO column) – V$SQL, V$SQLAREA ( CPU_TIME, ELAPSED_TIME columns) – V$LATCH, V$LATCH_PARENT, V$LATCH_CHILDREN ( WAIT_TIME column) – V$SQL_WORKAREA, V$SQL_WORKAREA_ACTIVE ( ACTIVE_TIME column) Views that include millisecond timings: – V$ENQUEUE_STAT ( CUM_WAIT_TIME column)
37
3-37 Copyright © 2006, Oracle. All rights reserved. Time Model: Overview The time model is a set of statistics that give an overview of where time is spent inside the Oracle database. All statistics use the same dimension: time. The statistics are accessible through: – V$SYS_TIME_MODEL – V$SESS_TIME_MODEL DB time represents the total time spent in database calls. Tuning goal is to reduce DB time. Using DB time, you can gauge the performance impact of any entity of the database. SQL PLSQL Connect Parse Java DB time
38
3-38 Copyright © 2006, Oracle. All rights reserved. Time Model Statistics Hierarchy Failed parse (out of shared memory) elapsed time DB time DB CPU Connection management call elapsed time Sequence load elapsed time SQL execute elapsed time Parse time elapsed Hard parse elapsed time Hard parse (sharing criteria) elapsed time Hard parse (bind mismatch) elapsed time Failed parse elapsed time PL/SQL execution elapsed time Inbound PL/SQL RPC elapsed time PL/SQL compilation elapsed time Java execution elapsed time Repeated bind elapsed time Background elapsed time Background CPU time RMAN CPU time (backup/restore)
39
3-39 Copyright © 2006, Oracle. All rights reserved. Notes only slide
40
3-40 Copyright © 2006, Oracle. All rights reserved. Practice Overview: Use Basic Tools This practice covers the following topics: Use the alert log information for tuning View system statistics View wait events
41
3-41 Copyright © 2006, Oracle. All rights reserved. Summary In this lesson, you should have learned how to: Identify dynamic performance views useful in tuning Identify key tuning components of the alert log file Identify key tuning components of user trace files Use dynamic performance views to view statistics and wait events
42
3-42 Copyright © 2006, Oracle. All rights reserved.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.