V $ sqltext: the complete SQL statement is stored, and the SQL statement is segmented. v $ sqlarea: the stored SQL statement and related information, such as the cumulative number of executions, logical reads, statistical information such as physical reads (Statistics) v $ SQL: resolved SQL statements in the memory shared SQL area. (Instant) selectopname, target, to_char (start_time, yyyy-mm-ddhh24: m
V $ sqltext: the complete SQL statement is stored, and the SQL statement is segmented. v $ sqlarea: the stored SQL statement and related information, such as the cumulative number of executions, logical reads, statistical information such as physical reads (Statistics) v $ SQL: resolved SQL statements in the memory shared SQL area. (Instant) selectopname, target, to_char (start_time, 'yyyy-mm-ddhh24: m
V $ sqltext: complete SQL statements are stored and separated.
V $ sqlarea: the stored SQL statements and related information, such as the cumulative number of executions, logical reads, physical reads, and other statistical information (Statistics)
V $ SQL: the parsed SQL statements in the memory shared SQL area. (Instant)
Select opname, target, to_char (start_time, 'yyyy-mm-dd hh24: mi: ss') start_time, elapsed_seconds elapsed,
Executions execs, buffer_gets/decode (executions, 0, 1, executions) bufgets, module, SQL _text
From v $ session_longops sl, v $ sqlarea sa
Where sl. SQL _hash_value = sa. hash_value
And upper (substr (module, 1, 4) <> 'rman'
And substr (opname, 1, 4) <> 'rman'
And sl. start_time> trunc (sysdate)
Order by start_time;
Find the complete SQL statement based on the sid:
Select SQL _text from v $ sqltext a where a. hash_value = (select SQL _hash_value from v $ session B where B. sid = '& sid ')
Order by piece asc
Select a. CPU_TIME, -- one thousandth of CPU time (microseconds)
A. OPTIMIZER_MODE, -- Optimization Method
A. EXECUTIONS, -- number of EXECUTIONS
A. DISK_READS, -- number of disk reads
A. SHARABLE_MEM, -- the amount of memory occupied by the shared pool
A. BUFFER_GETS, -- number of times the buffer is read
A. COMMAND_TYPE, -- command type (3: select, 2: insert; 6: update; 7 delete; 47: pl/SQL program Unit)
A. SQL _TEXT, -- SQL statement
A. SHARABLE_MEM,
A. PERSISTENT_MEM,
A. RUNTIME_MEM,
A. parse_cils,
A. DISK_READS,
A. DIRECT_WRITES,
A. CONCURRENCY_WAIT_TIME,
A. USER_IO_WAIT_TIME
From SYS. V _ $ SQLAREA
WHERE PARSING_SCHEMA_NAME = 'chea _ FILL '-- tablespace
Order by a. CPU_TIME desc
Reference: http://jenniferok.iteye.com/blog/700985
Query the most resource-consuming query from V $ SQLAREA
Select B. username, a. disk_reads reads,
A.exe cutions exec, a. disk_reads/decode(a.executions,, a.exe cutions) rds_exec_ratio,
A. SQL _text Statement
From v $ sqlarea a, dba_users B
Where a. parsing_user_id = B. user_id
And a. disk_reads> 100000
Order by a. disk_reads desc;
Replace the disk_reads column with the buffer_gets column to obtain information about the SQL statements that occupy the most memory.
V $ SQL: the parsed SQL statements in the memory shared SQL area. (Instant)
List the five most frequently used queries:
Select SQL _text, executions
From (select SQL _text, executions,
Rank () over
(Order by executions desc) exec_rank
From v $ SQL)
Where exec_rank <= 5;
Top 5 SQL statements that consume the most disk reads:
Select disk_reads, SQL _text
From (select SQL _text, disk_reads,
Dense_rank () over
(Order by disk_reads desc) disk_reads_rank
From v $ SQL)
Where disk_reads_rank <= 5;
Find the query that requires a large number of buffer read (logical read) operations:
Select buffer_gets, SQL _text
From (select SQL _text, buffer_gets,
Dense_rank () over
(Order by buffer_gets desc) buffer_gets_rank
From v $ SQL)
Where buffer_gets_rank <= 5;
V $ sqlarea field definition: http://happyhou.blog.sohu.com/60494432.html
SQL_TEXT |
VARCHAR2(1000) |
First thousand characters of the SQL text for the current cursor |
SQL_ID |
VARCHAR2(13) |
SQL identifier of the parent cursor in the library cache |
SHARABLE_MEM |
NUMBER |
Amount of shared memory used by a cursor. If multiple child cursors exist, then the sum of all shared memory used by all child cursors. |
PERSISTENT_MEM |
NUMBER |
Fixed amount of memory used for the life time of an open cursor. If multiple child cursors exist, the fixed sum of memory used for the life time of all the child cursors. |
RUNTIME_MEM |
NUMBER |
Fixed amount of memory required during execution of a cursor. If multiple child cursors exist, the fixed sum of all memory required during execution of all the child cursors. |
SORTS |
NUMBER |
Sum of the number of sorts that were done for all the child cursors |
VERSION_COUNT |
NUMBER |
Number of child cursors that are present in the cache under this parent |
LOADED_VERSIONS |
NUMBER |
Number of child cursors that are present in the cache and have their context heap (KGL heap 6) loaded |
OPEN_VERSIONS |
NUMBER |
The number of child cursors that are currently open under this current parent |
USERS_OPENING |
NUMBER |
Number of users that have any of the child cursors open |
FETCHES |
NUMBER |
Number of fetches associated with the SQL statement |
EXECUTIONS |
NUMBER |
Total number of executions, totalled over all the child cursors |
END_OF_FETCH_COUNT |
NUMBER |
Number of times this cursor was fully executed since the cursor was brought into the library cache. the value of this statistic is not incremented when the cursor is partially executed, either because it failed during the execution or because only the first few rows produced by this cursor are fetched before the cursor is closed or re-executed. by definition, the value ofEND_OF_FETCH_COUNT Column shoshould be less or equal to the value ofEXECUTIONS Column. |
USERS_EXECUTING |
NUMBER |
Total number of users executing the statement over all child cursors |
LOADS |
NUMBER |
Number of times the object was loaded or reloaded |
FIRST_LOAD_TIME |
VARCHAR2(19) |
Timestamp of the parent creation time |
INVALIDATIONS |
NUMBER |
Total number of invalidations over all the child cursors |
PARSE_CALLS |
NUMBER |
Sum of all parse callto all the child cursors under this parent |
DISK_READS |
NUMBER |
Sum of the number of disk reads over all child cursors |
DIRECT_WRITES |
NUMBER |
Sum of the number of direct writes over all child cursors |
BUFFER_GETS |
NUMBER |
Sum of buffer gets over all child cursors |
APPLICATION_WAIT_TIME |
NUMBER |
Application wait time |
CONCURRENCY_WAIT_TIME |
NUMBER |
Concurrency wait time |
CLUSTER_WAIT_TIME |
NUMBER |
Cluster wait time |
USER_IO_WAIT_TIME |
NUMBER |
User I/O Wait Time |
PLSQL_EXEC_TIME |
NUMBER |
PL/SQL execution time |
JAVA_EXEC_TIME |
NUMBER |
Java execution time |
ROWS_PROCESSED |
NUMBER |
Total number of rows processed on behalf of this SQL statement |
COMMAND_TYPE |
NUMBER |
Oracle command type definition |
OPTIMIZER_MODE |
VARCHAR2(25) |
Mode under which the SQL statement was executed |
PARSING_USER_ID |
NUMBER |
User ID of the user that has parsed the very first cursor under this parent |
PARSING_SCHEMA_ID |
NUMBER |
Schema ID that was used to parse this child cursor |
KEPT_VERSIONS |
NUMBER |
Number of child cursors that have been marked to be kept usingDBMS_SHARED_POOL Package |
ADDRESS |
RAW(4 | 8) |
Address of the handle to the parent for this cursor |
HASH_VALUE |
NUMBER |
Hash value of the parent statement in the library cache |
OLD_HASH_VALUE |
NUMBER |
Old SQL hash value |
MODULE |
VARCHAR2(64) |
Contains the name of the module that was executing at the time that the SQL statement was first parsed as set by callingDBMS_APPLICATION_INFO .SET_MODULE |
MODULE_HASH |
NUMBER |
Hash value of the module that is named inMODULE Column |
ACTION |
VARCHAR2(64) |
Contains the name of the action that was executing at the time that the SQL statement was first parsed as set by callingDBMS_APPLICATION_INFO .SET_ACTION |
ACTION_HASH |
NUMBER |
Hash value of the action that is named inACTION Column |
SERIALIZABLE_ABORTS |
NUMBER |
Number of times the transaction fails to serialize, producingORA-08177 Errors, totalled over all the child cursors |
CPU_TIME |
NUMBER |
CPU time (in microseconds) used by this cursor for parsing/executing/fetching |
ELAPSED_TIME |
NUMBER |
Elapsed time (in microseconds) used by this cursor for parsing/executing/fetching |
IS_OBSOLETE |
VARCHAR2(1) |
Indicates whether the cursor has become obsolete (Y ) Or not (N ). This can happen if the number of child cursors is too large. |
CHILD_LATCH |
NUMBER |
Child latch number that is protecting the cursor |
PROGRAM_ID |
NUMBER |
Program identifie |