Performance Tuning Tools
We have discussed the tools that are being used for Performance Tuning in our previous article.
Please find the article here
In this article we will be discussing the additional tools which are used in Performance Tuning.
- V$Dynamic Perfromance Views
- Oracle Enterprise Manager (OEM)
- AWR, ADDM, ASH reports
- SQL Tuning advisor and baselines
- OS Monitoring
V$ Dynamic Performance Views:
V$ VIEWS are the part of X$ fixed tables. V$ dynamic views are from the memory directly giving the real time data. If the DB is restarted, the historical information from these V$ dynamic views are not available. This is the reason when the DB IS restarted between the 2 awr snapshot IDs, we cannot generate the awr report.
Some of the important and frequently used V$ views which we are using to tune the Oracle Database are as follows.
- V$SYSSTAT – This has the performance statistics of the database upto 500 records.
- V$SESSION – Information of all the users that are connected to the Database.
- V$SESSTAT – To get the detailed statistics of the session from v$session
- V$PROCESS – Contains the information of the processes at server process level.
- V$SQL, V$SQL_PLAN, V$SQL_PLAN_STATISTICS
There are many V$ views that are going to help us in the tuning, but the above are the most commonly used dynamic views.
In tuning practices a set of V$ tables has the most important information which is needed to tune is are the “wait interface tables”. When you query a statement, it spends some time to execute the Oracle Code which will actually consume the CPU. Any statement that is being executed must and will consume some CPU. But oracle needs to wait for some activity to be finished before executing the oracle code. The cycle of executing a statement would be like the program has to go inside the CPU, process it, execute the code and then fetch the records. So in order to perform this activity, the process might be on wait to get the available resources.
For example, if there are 2 sqls that are already running then the processes and CPUs are busy in executing these SQLs. So, if a new request comes, it must wait to finish the already executing sqls so that the CPU and process will be free and available in executing the new request. The most notably, IO requests have to be finished for the internal resources like locks and latches to be available. This information of number and the duration of the wait times will be recorded by the wait interface.
Time model tables are introduced from the Oracle 10g which gives the details of the time information like DB time, Elapsed time, Parsing times etc. So from this we can know for how long the wait existed, for how much time the process has been waiting for executing a statement or a program.
SQL> desc V$SYSTEM_EVENT
Name Null? Type
----------------------------------------- -------- ----------------------------
To get a summary of the waits experienced in the database at a high-level, below query is useful.
SELECT WAIT_CLASS,EVENT,TOTAL_WAITS AS WAITS, ROUND (TIME_WAITED_MICRO/1000) AS TOTAL_MS,
ROUND (TIME_WAITED*1000/SUM(TIME_WAITED_MICRO) OVER(),2) AS PCT_TIME,
ROUND ((TIME_WAITED_MICRO/TOTAL_WAITS)/1000,2) AS AVG_MS FROM V$system_event WHERE wait_class <> 'Idle' ORDER BY time_waited_micro DESC;
The time model data can be shown as a whole for the database in V$SYS_TIME_MODEL and for individual session in V$SESS_TIME_MODEL. Below are the statistics from the views.
DB Time – Shows the elapsed time in microseconds spent executing the requests. This includes all
the user SQLs but not from the background processes.
DB CPU – CPU time spent executing the requests in microseconds. This includes all the user SQLs but not from the background processes.
Background elapsed Time – Shows the elapsed time spent by the background processes in microseconds.
Background CPU time – Shows the CPU time consumed by the background processes.
Sequence load elapsed time – Shows the time took for loading the sequence numbers to cache. This is when an application uses the numbers defined in the CACHE of Create Sequence clause.
Parse time elapsed – Shows the total time taken for parsing the SQLs.
Failed parse elapsed time – Shows the time spent on the failed parse requests.
- Background elapsed time is the combination of the background CPU time and background wait time.
- DB time includes the following
- DB CPU
- User wait time (from the wait interface)
- Connection management call elapsed time
- Sequence load elapsed time
- SQL executing time
- Parse time
- Hard parse elapsed time – If it is hard parsing then it is by sharing criteria or by the bind variable mismatch.
- Failed parse elapsed time – If it is failed parse then it is by out of memory.
- PL/SQL execution elapsed time
- Inbound PL/SQL rpc elapsed time
- PL/SQL compilation elapsed time
- Java execution elapsed time
Oracle Enterprise Manager (OEM) is user friendly tool with which we can easily monitor the performance of a database by navigating to the different tabs (windows) and can easily understand where is the actual problem through the graphical outputs. But this needs an additional licence.
Through OEM we can see the graphical outputs of the statistics, CPU time, DB time etc and these will be from the V$ Dynamic performance Views only
AWR, ADDM, ASH reports
AWR (Automatic Workload Repository) gathers, processes and maintains performance stats for problem detection and for self-tuning. The data is stored both in memory and database. So the data gathered is shown in report as well as in views. We can see the report in HTML or text for the current database performance status and analysis.
The AWR is used to collect performance statistics including:
- Wait events used to identify performance problems.
- Time model statistics indicating the amount of DB time associated with a process from the V$SESS_TIME_MODEL and V$SYS_TIME_MODEL views.
- Active Session History (ASH) statistics from the V$ACTIVE_SESSION_HISTORY view.
- Some system and session statistics from the V$SYSSTAT and V$SESSTAT views.
- Object usage statistics.
- Resource intensive SQL statements.
Different Components that uses AWR are:
- Automatic Database Diagnostic Monitor
- Undo Advisor
- SQL Tuning Advisor
- Segment Advisor
By default the snapshots are generated hourly basis and keeps the statistics in repository for 8 days. We can also modify the default setting as per the requirement using the below statement.
BEGIN DBMS_WORKLOAD_REPOSITORY.MODIFY_SNAPSHOT_SETTINGS( retention => 14400, interval => 15, topnsql => 100, dbid => 12345678); END; /
Here , Retention = 14400 minutes (10 days)
Snapshot retention period Interval = 15 minutes Snapshot interval period
topnsql = Number of Top SQL to flush
dbid = database identifier
Different types of AWR Reports for different purposes:
For Single Instance Environment: @$ORACLE_HOME/rdbms/admin/awrrpt.sql
For Oracle RAC Environment : @$ORACLE_HOME/rdbms/admin/awrgrpt.sql
For a particular SQL Statement : @$ORACLE_HOME/rdbms/admin/awrsqrpt.sql
For Comparing the reports : @$ORACLE_HOME/rdbms/admin/awrddrpt.sql
By default, gathering statistics using AWR is enabled and controlled by STATISTICS_LEVEL initializing parameter. This should be set to TYPICAL or ALL to enable. Default setting is Typical and if we set it to Basic, this will disable many features of Oracle Database which includes AWR. So, Oracle does not recommend to set it to basic.
SQL> show parameter statistics;
NAME TYPE VALUE
optimizer_use_pending_statistics boolean FALSE
statistics_level string TYPICAL
timed_os_statistics integer 0
timed_statistics boolean TRUE
We can also manually capture the AWR repots using the DBMA_WORKLOAD_REPOSITORY package but segment statistics, memory advisory information etc will be disabled.
The space consumed in the sysaux tablespace by the AWR depends on the snapshot time, active sessions and the retention period. If the snapshot time is 15mins then the data gathered will be more and specific and thus, the space consumed will be more. And if the snapshot is 1 hour the space consumption will be less and the data will be based on the one-hour interval.
ADDM (Automatic Database Diagnostic Monitor)
This is a server-based expert that reviews the database performance for every 60 min by default. ADDM will reads all the AWR snapshots and try to detect the problems and advises us the best solutions that we can apply to get rid of the problems in the database.
ADDM recommends multiple solutions like
- CPU Bottlenecks
- Undersized memory structures
- I/O capacity issues
- RAC specific issues
- High load sql statements
- Database Configuration
- Hardware changes
- Schema changes
- Application changes &
- Other advisories
ASH (Active Session History):
Active Session History Reports shows you the below mentioned stats regarding your Oracle Database,
- Transient performance problems (usually not captured in ADDM reports)
- Time / session / action /module / SQL_ID based target performance analysis
Below mentioned is the script which you can run to generate your ASH report,
For Oracle RAC Environment :
ASH reports Give the following information:
- Top User Events (frequent wait events)
- Details to the wait events
- Top Queries
- Top Sessions
- Top Blocking Sessions
- Top DB Object.
- Activity Over Time
Here AWR, ADDM & ASH is used for Instance level tuning whereas the V$ Dynamic views are used for SQL and Instance level tuning.
TO BE CONTINUED…