Oracle Database 11g: New Features for Administrators 15-1
Oracle Database 11g: New Features for Administrators 15-2
SQL Monitoring The real-time SQL monitoring feature on Oracle Database 11g enables you to monitor the performance of SQL statements while they are executing. The real-time SQL monitoring feature is enabled by default when the STATISTICS_LEVEL initialization parameter is either set to ALL or to TYPICAL, which is the default value. Additionally, the CONTROL_MANAGEMENT_PACK_ACCESS parameter must be set to DIAGNOSTIC+TUNING (the default value) because real-time SQL monitoring is a feature of the Oracle Database Tuning Pack. By default, real-time SQL monitoring is started when a SQL command runs in parallel, or when it has consumed at least five seconds of the CPU or I/O time in a single execution. As mentioned, real-time SQL monitoring is active by default. However, two command-level hints are available to force or prevent a SQL command from being monitored. To force real-time SQL monitoring, use the MONITOR hint. To prevent the hinted SQL command from being monitored, use the NO_MONITOR hint. Oracle Database 11g: New Features for Administrators 15-3
SQL Monitoring (continued) You can monitor the statistics for SQL command execution using the V$SQL_MONITOR and V$SQL_PLAN_MONITOR views. After monitoring is initiated, an entry is added to the V$SQL_MONITOR dynamic performance view. This entry tracks key performance metrics collected for the execution, including the elapsed time, CPU time, number of reads and writes, I/O wait time, and various other wait times. These statistics are refreshed in near real time as the command executes, generally once every second. After the execution ends, monitoring information is not deleted immediately, but is kept in the V$SQL_MONITOR view for at least one minute. The entry is eventually deleted so its space can be reclaimed as new commands are monitored. The V$SQL_MONITOR and V$SQL_PLAN_MONITOR views can be used in conjunction with the following views to get additional information about the execution that is monitored: V$SQL, V$SQL_PLAN, V$ACTIVE_SESSION_HISTORY, V$SESSION_LONGOPS, and V$SESSION Instead, you can use the SQL monitoring report to view SQL monitoring data. Oracle Database 11g: New Features for Administrators 15-4
SQL Monitoring in Oracle Database 11g Release 2 In Oracle Database 11g Release 2, you can access the SQL Monitoring feature in Enterprise Manager Database Control by clicking the Performance tab. You can choose from Real Time and Historical Settings. Scroll down to the Additional Monitoring Links area and click SQL Monitoring, as shown in the slide. Note: The COMPATIBLE initialization parameter must be set to 11.2.0.0 (or higher) to use this feature. Oracle Database 11g: New Features for Administrators 15-5
SQL Monitoring with Enterprise Manager Database Control This slide shows just one possible work flow in Enterprise Manager Database Control. You can navigate through the following pages: Monitored SQL Execution SQL Execution Details Session Details SQL Details Oracle Database 11g: New Features for Administrators 15-6
Monitored SQL Executions When you move the cursor over the values or symbols of each SQL execution, a relevant hint appears. The slide shows the actual SQL command being executed with the cursor on the SQL ID link. When you click the link that shows the SQL ID, you navigate to the Monitored SQL Execution Details page, as shown in the following slide. Oracle Database 11g: New Features for Administrators 15-7
SQL Monitoring List This slide shows another example of monitored SQL executions. 1. In the top left section, you see for each long-running SQL, the completion status (which can be executing, done, or error), execution duration (wall clock time), SQL ID, and Session ID where the SQL was executed. 2. Here you see the database time by wait class, and I/O read and write operations. 3. This detail shows you the degree of parallelism: the number of instances that are involved in this parallel execution. 4. Here you see that the execution of the SQL command is completed. Oracle Database 11g: New Features for Administrators 15-8
Monitored SQL Execution Details The details of the SQL execution are displayed on three different tabbed pages: Plan Statistics, as shown in the bottom part of the slide Parallel, displaying the distribution of work across the parallel servers (not part of the example in the slide) Activity, displaying ASH data on a time line When you click the Session link, you navigate to the Session Details page. When you click the SQL ID link, you navigate to the SQL Details page. Oracle Database 11g: New Features for Administrators 15-9
SQL Execution Details for Parallel Queries This slide shows you the Plan Statistics tabbed page for the SQL execution of parallel queries. Oracle Database 11g: New Features for Administrators 15-10
Details for Parallel Execution This slide shows you monitored SQL execution details for parallel queries (on the Parallel tabbed page). Oracle Database 11g: New Features for Administrators 15-11
Activity Details for Parallel Execution This Activity tabbed page displays the activity graphs for parallel queries. You see the oscillation of CPU and direct reads over time. Oracle Database 11g: New Features for Administrators 15-12
Viewing Session Details This page shows you the session details for the MONI user, divided into the following sections: Server Client Application Contention Wait Other When you click the Current SQL link, you navigate to the SQL Details page, as shown in the following slide. Oracle Database 11g: New Features for Administrators 15-13
SQL Details When you click the SQL Monitoring tab, you navigate to the Monitored SQL Execution page. Oracle Database 11g: New Features for Administrators 15-14
Viewing the SQL Monitoring Report The SQL Monitoring Report shows the same information as the previous slides, but this time in a textual, rather than a graphic way. It begins with the SQL Text, followed by global information, and then the SQL Plan Monitoring details, which also indicates the current operation with an arrow. When you see the new Save and Mail buttons, you can also save the report in HTML format and email the Active Report for example, to a SQL Tuning expert, if your organization has such a division of work. Oracle Database 11g: New Features for Administrators 15-15
Answers: 1, 2, 5 Oracle Database 11g: New Features for Administrators 15-16
Oracle Database 11g: New Features for Administrators 15-17
Oracle Database 11g: New Features for Administrators 15-18