The DBMS_SQL_MONITOR
package provides information about Real-time SQL Monitoring and Real-time Database Operation Monitoring.
See Also:
DBMS_SQLTUNEThis chapter contains the following topics:
Overview
Security Model
Constants
The DBMS_SQL_MONITOR
package provides information about Real-time SQL Monitoring and Real-time Database Operation Monitoring. These features provide automatic monitoring of SQL statements, PL/SQL blocks, or composite database operations that are considered expensive. A simple database operation is a single SQL statement or PL/SQL procedure or function. A composite database operation is activity between two defined points in time in a database session. The monitored data is collected in V$SQL_MONITOR
and V$SQL_PLAN_MONITOR
.
The following subprograms begin and end monitoring of a composite database operation:
The following subprograms report on monitoring data collected in V$SQL_MONITOR
and V$SQL_PLAN_MONITOR
:
This package is available to PUBLIC
and executes with invoker's rights privileges.The reporting functions require privileges to select data from the catalog as provided by the role SELECT_CATALOG_ROLE
.
The DBMS_SQL_MONITOR
package uses the constants shown in Table 151-1, "DBMS_SQL_MONITOR Constants".
Table 151-1 DBMS_SQL_MONITOR Constants
Constant | Type | Value | Description |
---|---|---|---|
|
|
|
Force track the composite database operation when the operation starts |
|
|
|
Do not force track the composite database operation when the operation starts. It is only tracked when it has consumed 5 seconds of CPU or I/O time. |
Table 151-2 DBMS_SQL_MONITOR Package Subprograms
Subprogram | Description |
---|---|
Starts a composite database operation in the current session |
|
Ends the monitoring operation in the current session |
|
Builds a detailed report for a specific database operation that has been monitored by Oracle |
|
Builds a report for all or a subset of database operations that have been monitored by Oracle |
This function starts a composite database operation in the current session.
DBMS_SQL_MONITOR.BEGIN_OPERATION ( dbop_name IN VARCHAR2, dbop_eid IN NUMBER := NULL, forced_tracking IN VARCHAR2 := NO_FORCE_TRACKING, attribute_list IN VARCHAR2 := NULL) RETURN NUMBER;
Table 151-3 BEGIN_OPERATION Procedure Parameters
Parameter | Description |
---|---|
|
Name for the composite database operation |
|
Unique identifier for the current execution of the composite database operation |
|
Values: (see defined Constants):
|
|
List of user-created attributes. It is a comma-separated list of name-value pairs (for example, |
This function ends a composite database operation in the current session. If the specified composite database operation does not exist, this procedure has no effect.
This function builds a detailed report with monitoring information for a simple or a composite database operation. For each operation, it gives key information and associated global statistics. Use this function to get detailed monitoring information for a simple or a composite database operation.
The target database operation for this report can be:
The last database operation monitored by Oracle (default, no parameter)
The last database operation executed in the specified session and monitored by Oracle. The session is identified by its session ID and optionally its serial number (-1
is current session).
The last execution of a specific database operation identified by its sql_id
A specific execution of a database operation identified by the combination sql_id
, sql_exec_start
, nd sql_exec_id
The last execution of a specific composite database operation identified by dbop_name
The specific execution of a composite database operation identified by the combination dbop_name
, dbop_exec_id
DBMS_SQL_MONITOR.REPORT_SQL_MONITOR ( sql_id IN VARCHAR2 DEFAULT NULL, dbop_name IN VARCHAR2 DEFAULT NULL, dbop_exec_id IN NUMBER DEFAULT NULL, session_id IN NUMBER DEFAULT NULL, session_serial IN NUMBER DEFAULT NULL, sql_exec_start IN DATE DEFAULT NULL, sql_exec_id IN NUMBER DEFAULT NULL, inst_id IN NUMBER DEFAULT NULL, start_time_filter IN DATE DEFAULT NULL, end_time_filter IN DATE DEFAULT NULL, instance_id_filter IN NUMBER DEFAULT NULL, parallel_filter IN VARCHAR2 DEFAULT NULL, plan_line_filter IN NUMBER DEFAULT NULL, event_detail IN VARCHAR2 DEFAULT 'YES', bucket_max_count IN NUMBER DEFAULT 128, bucket_interval IN NUMBER DEFAULT NULL, base_path IN VARCHAR2 DEFAULT NULL, last_refresh_time IN DATE DEFAULT NULL, report_level IN VARCHAR2 DEFAULT 'TYPICAL', type IN VARCHAR2 DEFAULT 'TEXT', sql_plan_hash_value IN NUMBER DEFAULT NULL, con_name IN VARCHAR2 DEFAULT NULL) RETURN CLOB;
Table 151-5 REPORT_SQL_MONITOR Procedure Parameters
Parameter | Description |
---|---|
|
|
|
|
|
Execution ID for the composite database operation for which monitoring information is displayed |
|
Targets only the subset of statements executed and monitored on behalf of the specified session. Default is |
|
In addition to |
|
Time at which execution of the monitored SQL was started. Only applicable when |
|
A numeric ID generated internally by SQL monitor to identify different executions of the same SQL statement. Thus each execution will have the same |
|
Looks only at queries started on the specified instance. Use |
|
If not |
|
If not |
|
Only looks at activity for the specified instance. Use |
|
Parallel filter applies only to parallel execution and allows you to select only a subset of the processes involved in the parallel execution. The string
|
|
Selects activity and execution statistics for the specified line number in the plan of a SQL |
|
When set to |
|
Specifies the maximum number of buckets to create in the report |
|
Represents the exact time interval, in seconds, of all histogram buckets. If specified, |
|
URL path for flex HTML resources since flex HTML format requires access to external files (java scripts and the flash |
|
If not
|
|
Level of detail for the report. Of the following, only one can be specified:
In addition, individual report sections can also be enabled or disabled by using a
In addition, SQL text can be specified at different levels:
|
|
Report type:
|
|
Targets only those with the specified plan hash value. Default is |
|
Container name |
This function builds a report for all or a subset of database operations that have been monitored by Oracle. For each database operation, it gives key information and associated global statistics.
DBMS_SQL_MONITOR.REPORT_SQL_MONITOR_LIST ( sql_id IN VARCHAR2 DEFAULT NULL, dbop_name IN VARCHAR2 DEFAULT NULL, monitor_type IN NUMBER DEFAULT MONITOR_TYPE_ALL, session_id IN NUMBER DEFAULT NULL, session_serial IN NUMBER DEFAULT NULL, inst_id IN NUMBER DEFAULT NULL, active_since_date IN DATE DEFAULT NULL, active_since_sec IN NUMBER DEFAULT NULL, last_refresh_time IN DATE DEFAULT NULL, report_level IN VARCHAR2 DEFAULT 'TYPICAL', auto_refresh IN NUMBER DEFAULT NULL, base_path IN VARCHAR2 DEFAULT NULL, type IN VARCHAR2 DEFAULT 'TEXT', con_name IN VARCHAR2 DEFAULT NULL) RETURN CLOB;
Table 151-6 REPORT_SQL_MONITOR_LIST Procedure Parameters
Parameter | Description |
---|---|
|
|
|
|
|
Monitor type:
|
|
Targets only the subset of database operations executed and monitored on behalf of the specified session. Default is |
|
In addition to |
|
Looks only at monitored database operations originating from the specified instance. Use |
|
If not |
|
If not |
|
If not |
|
Level of detail for the report. The level can be |
|
Specifies the duration in seconds after which report data will be automatically refreshed while the monitored SQL or database operation is still executing. This applies to active report types. |
|
URL path for flex HTML resources since flex HTML format requires access to external files (java scripts and the flash |
|
Report type:
|
|
Container name |
Use the REPORT_SQL_MONITOR Function to get detailed monitoring information for a single database operation.
The user invoking this function needs to have the privilege to access the fixed views GV$SQL_MONITOR
and GV$SQL
.