sql-monitor-brief

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Business / Technical Brief

Real-Time SQL Monitoring


and Oracle Database
In-Memory

March 2023, Version 1.10


Copyright © 2023, Oracle and/or its affiliates
Public

1 Business / Technical Brief / Real-Time SQL Monitoring and Oracle Database


In-Memory / Version 1.10
Copyright © 2023, Oracle and/or its affiliates / Public
Purpose
Real-Time SQL Monitoring is an excellent tool for evaluating Database In-Memory SQL
execution plans because it shows where time is spent during SQL execution. This brief will
More information on Real-
explain how to use active SQL Monitor reports to help determine the benefits that
Time SQL Monitoring can be
Database In-Memory provides to SQL execution. It will show you what has changed in found in the following
Real-Time SQL Monitoring, how to enable active SQL Monitor reports and how to documentation:
determine when Database In-Memory is being used.
• Oracle Database:
Database SQL Tuning
Note: Real-Time SQL Monitoring requires the Oracle Database Tuning Pack Guide
• Oracle Database:
What Has Changed? Database PL/SQL
Packages and Types
In Oracle Database 12c Real-Time SQL Monitoring was moved to its own package. Prior to Reference
Oracle Database 12c it was part of the dbms_sqltune package and now it is part of the • Oracle Exadata System
dbms_sql_monitor package. The subprogram remains the REPORT_SQL_MONITOR Software User's Guide
function. Also starting in Oracle Database 12c active SQL Monitor reports support • Real-Time SQL Monitoring
Database In-Memory by showing CPU consumed by Database In-Memory specifically as (oracle.com)

opposed to other types of CPU consumption. In Oracle Database 19c the format of SQL • Oracle is deprecating
Flash-based Oracle
Monitor active reports has changed to Java JET technology and no longer uses Flash. Enterprise Manager
Express
How Do I Access Active SQL Monitor Reports?
Active SQL Monitor reports can be accessed directly from Enterprise Manager Cloud
Control or Enterprise Manager Database Express (EM Express) using the "Monitored SQL"
tab from the Performance Hub (accessed from the Performance menu). SQL Monitor
reports can also be accessed through SQL Developer, but the format is not the same as an
active SQL Monitor report. The following shows how to select an active SQL monitor
report from EM Express:

Alternatively, active SQL monitor reports can be created using the PL/SQL function
dbms_sql_monitor.report_sql_monitor() using the "active" report type. For example, the
following SQL*Plus script shows how to generate an active report for the statement that
was monitored last by Oracle:
set trimspool on
set trim on
set pagesize 0
set linesize 32767
set long 1000000
set longchunksize 1000000
spool sqlmon_active.html
select dbms_sql_monitor.report_sql_monitor(
report_level=>'ALL',type=>'ACTIVE')
from dual;
spool off

2 Business / Technical Brief / Real-Time SQL Monitoring and Oracle Database


In-Memory / Version 1.10
Copyright © 2023, Oracle and/or its affiliates / Public
Requirements
SQL Monitoring requires:

• A Diagnostics and Tuning Pack License.


• STATISTICS_LEVEL parameter to be set to 'TYPICAL' or 'ALL'.
• CONTROL_MANAGEMENT_PACK_ACCESS parameter set to 'DIAGNOSTIC+TUNING'.
By default, a SQL statement will be monitored when any of the following conditions are
true:

• The operations run in parallel.


• The operations have consumed at least 5 seconds of CPU or I/O time in a single
execution.
• Tracking for the operations is forced by the /*+ MONITOR */ hint.
You can also set an event based on SQL_ID to force SQL monitoring (MOS Note:
2555350.1) :

• ALTER SYSTEM SET EVENTS 'sql_monitor [sql:5hc07qvt8v737]


force=true';

• To disable replace force=true with off.

By default, SQL Monitor will only monitor plans that are 300 lines or less. This can be
increased with the parameter _SQLMON_MAX_PLANLINES (MOS Note: 1613163.1).

You can also change the default run time threshold of 5 seconds with the parameter
_SQLMON_THRESHOLD.

What Does an Active SQL Monitor Report Look Like?


Active SQL Monitor reports use Enterprise Manager UI technology and require JavaScript
and SWF files to render the report and are hosted remotely on the Oracle Technology
Network (OTN) website. The 19c Java JET based active SQL monitor report looks like the
following:

3 Business / Technical Brief / Real-Time SQL Monitoring and Oracle Database


In-Memory / Version 1.10
Copyright © 2023, Oracle and/or its affiliates / Public
Active SQL Monitor reports provide several advantages over traditional "explain plan"
techniques. The biggest one is the ability to visualize where time was spent during the
execution of the SQL statement. No more guessing as to what actually happened and
what areas of the statement to target. In addition to the timing information is the ability to
hover over the bar graphs, as well as other parts of the report, and highlight what the
usage corresponds to. In the following example we can see that 100% of the activity is
attributable to "CPU: IN MEMORY":

And this can also be seen in the individual execution line activity as well. We see that the
TABLE ACCESS INMEMORY FULL scan of the LINEORDER table in line 6 accounted for
100% of the activity and was all attributed to "Cpu: in memory":

The ability to differentiate between CPU time spent "in memory" and other CPU time can
take the guess work out of determining whether Database In-Memory was used and help
identify where time was spent during the SQL execution.

Collecting SQL Monitor Reports for a Time Interval


What if you want to collect all SQL Monitor reports from a particular time period? For
example, when you are creating a baseline or evaluating changes made to the
environment like enabling Database In-Memory. The easiest thing to do is to create a
Performance Hub Report for the given time period. Ideally you will take an AWR snapshot
at the beginning and end of each of your test periods to help isolate the workload and
then you can generate the Performance Hub Report for just that time period. The nice
thing is that the Performance Hub Report will include all the SQL Monitor reports captured
during the time period specified for the report. This is documented in detail in the MOS
Note: Monitoring Database Performance Using Performance Hub Report (Doc ID
2436566.1).

Cell Memory
Active SQL Monitor reports can also show the benefits of Database In-Memory usage in
Exadata Smart Flash Cache (i.e., Cell Memory). Since this usage occurs on the Storage
Servers the usage is displayed when clicking on the binocular's icon in the same way that
benefits like In-Memory join groups or In-Memory vectorized joins are displayed. The
4 Business / Technical Brief / Real-Time SQL Monitoring and Oracle Database
In-Memory / Version 1.10
Copyright © 2023, Oracle and/or its affiliates / Public
following is an example that shows the information available from a TABLE ACCESS
STORAGE FULL when clicking on the binocular's icon on line 22:

Notice the statistics "Columnar cache saved bytes", "Flash cache bytes" and "IM Capacity
bytes". These statistics are documented in the Oracle Exadata System Software User's
Guide and show that data was read in Database In-Memory format from the Exadata
Smart Flash Cache. Note that this is only available on Exadata when Database In-Memory
has been enabled (i.e., INMEMORY_SIZE > 0 or
INMEMORY_FORCE=CELLMEMORY_LEVEL).

Connect with us

Call +1.800.ORACLE1 or visit oracle.com. Outside North America, find your local office at: oracle.com/contact.

blogs.oracle.com facebook.com/oracle twitter.com/oracle

Copyright © 2023, Oracle and/or its affiliates. All rights reserved. This document is Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be
provided for information purposes only, and the contents hereof are subject to change trademarks of their respective owners.
without notice. This document is not warranted to be error-free, nor subject to any other
Intel and Intel Xeon are trademarks or registered trademarks of Intel Corporation. All SPARC
warranties or conditions, whether expressed orally or implied in law, including implied
trademarks are used under license and are trademarks or registered trademarks of SPARC
warranties and conditions of merchantability or fitness for a particular purpose. We
International, Inc. AMD, Opteron, the AMD logo, and the AMD Opteron logo are trademarks or
specifically disclaim any liability with respect to this document, and no contractual
registered trademarks of Advanced Micro Devices. UNIX is a registered trademark of The Open
obligations are formed either directly or indirectly by this document. This document
Group. 0120
may not be reproduced or transmitted in any form or by any means, electronic or
mechanical, for any purpose, without our prior written permission. Disclaimer: If you are unsure whether your data sheet needs a disclaimer, read the revenue
recognition policy. If you have further questions about your content and the disclaimer
This device has not been authorized as required by the rules of the Federal
requirements, e-mail REVREC_US@oracle.com.
Communications Commission. This device is not, and may not be, offered for sale or
lease, or sold or leased, until authorization is obtained.

5 Business / Technical Brief / Real-Time SQL Monitoring and Oracle Database


In-Memory / Version 1.10
Copyright © 2023, Oracle and/or its affiliates / Public

You might also like