V$SQL
V$SQL
lists statistics on shared SQL areas without the GROUP BY
clause and contains one row for each child of the original SQL text entered. Statistics displayed in V$SQL
are normally updated at the end of query execution. However, for long running queries, they are updated every 5 seconds. This makes it easy to see the impact of long running SQL statements while they are still in progress.
Column | Datatype | Description |
---|---|---|
SQL_TEXT | VARCHAR2(1000) | First thousand characters of the SQL text for the current cursor |
SQL_FULLTEXT | CLOB | Full text for the SQL statement exposed as a CLOB column. The full text of a SQL statement can be retrieved using this column instead of joining with the V$SQLTEXT dynamic performance view. |
SQL_ID | VARCHAR2(13) | SQL identifier of the parent cursor in the library cache |
SHARABLE_MEM | NUMBER | Amount of shared memory used by the child cursor (in bytes) |
PERSISTENT_MEM | NUMBER | Fixed amount of memory used for the lifetime of the child cursor (in bytes) |
RUNTIME_MEM | NUMBER | Fixed amount of memory required during the execution of the child cursor |
SORTS | NUMBER | Number of sorts that were done for the child cursor |
LOADED_VERSIONS | NUMBER | Indicates whether the context heap is loaded (1 ) or not (0 ) |
OPEN_VERSIONS | NUMBER | Indicates whether the child cursor is locked (1 ) or not (0 ) |
USERS_OPENING | NUMBER | Number of users executing the statement |
FETCHES | NUMBER | Number of fetches associated with the SQL statement |
EXECUTIONS | NUMBER | Number of executions that took place on this object since it was brought into the library cache |
PX_SERVERS_EXECUTIONS | NUMBER | Total number of executions performed by parallel execution servers (0 when the statement has never been executed in parallel) |
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 of the END_OF_FETCH_COUNT column should be less or equal to the value of the EXECUTIONS column. |
USERS_EXECUTING | NUMBER | Number of users executing the statement |
LOADS | NUMBER | Number of times the object was either loaded or reloaded |
FIRST_LOAD_TIME | VARCHAR2(19) | Timestamp of the parent creation time |
INVALIDATIONS | NUMBER | Number of times this child cursor has been invalidated |
PARSE_CALLS | NUMBER | Number of parse calls for this child cursor |
DISK_READS | NUMBER | Number of disk reads for this child cursor |
DIRECT_WRITES | NUMBER | Number of direct writes for this child cursor |
BUFFER_GETS | NUMBER | Number of buffer gets for this child cursor |
APPLICATION_WAIT_TIME | NUMBER | Application wait time (in microseconds) |
CONCURRENCY_WAIT_TIME | NUMBER | Concurrency wait time (in microseconds) |
CLUSTER_WAIT_TIME | NUMBER | Cluster wait time (in microseconds) |
USER_IO_WAIT_TIME | NUMBER | User I/O Wait Time (in microseconds) |
PLSQL_EXEC_TIME | NUMBER | PL/SQL execution time (in microseconds) |
JAVA_EXEC_TIME | NUMBER | Java execution time (in microseconds) |
ROWS_PROCESSED | NUMBER | Total number of rows the parsed SQL statement returns |
COMMAND_TYPE | NUMBER | Oracle command type definition |
OPTIMIZER_MODE | VARCHAR2(10) | Mode under which the SQL statement was executed |
OPTIMIZER_COST | NUMBER | Cost of this query given by the optimizer |
OPTIMIZER_ENV | RAW(2000) | Optimizer environment |
OPTIMIZER_ENV_HASH_VALUE | NUMBER | Hash value for the optimizer environment |
PARSING_USER_ID | NUMBER | User ID of the user who originally built this child cursor |
PARSING_SCHEMA_ID | NUMBER | Schema ID that was used to originally build this child cursor |
PARSING_SCHEMA_NAME | VARCHAR2(30) | Schema name that was used to originally build this child cursor |
KEPT_VERSIONS | NUMBER | Indicates whether this child cursor has been marked to be kept pinned in the cache using theDBMS_SHARED_POOL package |
ADDRESS | RAW(4 | 8) | Address of the handle to the parent for this cursor |
TYPE_CHK_HEAP | RAW(4) | Descriptor of the type check heap for this child cursor |
HASH_VALUE | NUMBER | Hash value of the parent statement in the library cache |
OLD_HASH_VALUE | NUMBER | Old SQL hash value |
PLAN_HASH_VALUE | NUMBER | Numeric representation of the SQL plan for this cursor. Comparing one PLAN_HASH_VALUE to another easily identifies whether or not two plans are the same (rather than comparing the two plans line by line). |
CHILD_NUMBER | NUMBER | Number of this child cursor |
SERVICE | VARCHAR2(64) | Service name |
SERVICE_HASH | NUMBER | Hash value for the name listed in the SERVICE column |
MODULE | VARCHAR2(64) | Contains the name of the module that was executing at the time that the SQL statement was first parsed, which is set by calling DBMS_APPLICATION_INFO.SET_MODULE |
MODULE_HASH | NUMBER | Hash value of the module listed in the MODULE column |
ACTION | VARCHAR2(64) | Contains the name of the action that was executing at the time that the SQL statement was first parsed, which is set by calling DBMS_APPLICATION_INFO.SET_ACTION |
ACTION_HASH | NUMBER | Hash value of the action listed in the ACTION column |
SERIALIZABLE_ABORTS | NUMBER | Number of times the transaction failed to serialize, producing ORA-08177 errors, per cursor |
OUTLINE_CATEGORY | VARCHAR2(64) | If an outline was applied during construction of the cursor, then this column displays the category of that outline. Otherwise the column is left blank. |
CPU_TIME | NUMBER | CPU time (in microseconds) used by this cursor for parsing, executing, and fetching |
ELAPSED_TIME | NUMBER | Elapsed time (in microseconds) used by this cursor for parsing, executing, and fetching |
OUTLINE_SID | NUMBER | Outline session identifier |
CHILD_ADDRESS | RAW(4 | 8) | Address of the child cursor |
SQLTYPE | NUMBER | Denotes the version of the SQL language used for this statement |
REMOTE | VARCHAR2(1) | Indicates whether the cursor is remote mapped (Y ) or not (N ) |
OBJECT_STATUS | VARCHAR2(19) | Status of the cursor:
|
LITERAL_HASH_VALUE | NUMBER | Hash value of the literals which are replaced with system-generated bind variables and are to be matched, when CURSOR_SHARING is used. This is not the hash value for the SQL statement. IfCURSOR_SHARING is not used, then the value is 0 . |
LAST_LOAD_TIME | VARCHAR2(19) | Time at which the query plan was loaded into the library cache |
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. |
IS_BIND_SENSITIVE | VARCHAR2(1) | Indicates whether the cursor is bind sensitive (Y ) or not (N ). A query is considered bind-sensitive if the optimizer peeked at one of its bind variable values when computing predicate selectivities and where a change in a bind variable value may cause the optimizer to generate a different plan. |
IS_BIND_AWARE | VARCHAR2(1) | Indicates whether the cursor is bind aware (Y ) or not (N ). A query is considered bind-aware if it has been marked to use extended cursor sharing. The query would already have been marked as bind-sensitive. |
IS_SHAREABLE | VARCHAR2(1) | Indicates whether the cursor can be shared (Y ) or not (N ) |
CHILD_LATCH | NUMBER | Child latch number that is protecting the cursor. This column is obsolete and maintained for backward compatibility. |
SQL_PROFILE | VARCHAR2(64) | SQL profile used for this statement, if any |
SQL_PATCH | VARCHAR2(30) | SQL patch used for this statement, if any |
SQL_PLAN_BASELINE | VARCHAR2(30) | SQL plan baseline used for this statement, if any |
PROGRAM_ID | NUMBER | Program identifier |
PROGRAM_LINE# | NUMBER | Program line number |
EXACT_MATCHING_SIGNATURE | NUMBER | Signature calculated on the normalized SQL text. The normalization includes the removal of white space and the uppercasing of all non-literal strings. |
FORCE_MATCHING_SIGNATURE | NUMBER | Signature used when the CURSOR_SHARING parameter is set to FORCE |
LAST_ACTIVE_TIME | DATE | TIme at which the query plan was last active |
BIND_DATA | RAW(2000) | Bind data |
TYPECHECK_MEM | NUMBER | ??? |
V$SQL_WORKAREA
V$SQL_WORKAREA
displays information about work areas used by SQL cursors. Each SQL statement stored in the shared pool has one or more child cursors that are listed in the V$SQL
view. V$SQL_WORKAREA
lists all work areas needed by these child cursors; V$SQL_WORKAREA
can be joined with V$SQLAREA
on (ADDRESS
, HASH_VALUE
) and with V$SQL
on (ADDRESS
, HASH_VALUE
, CHILD_NUMBER
).
You can use this view to find out answers to the following questions:
- What are the top 10 work areas that require the most cache area?
- For work areas allocated in
AUTO
mode, what percentage of work areas are running using maximum memory?
Column | Datatype | Description |
---|---|---|
ADDRESS | RAW(4 | 8) | Address of the parent cursor handle |
HASH_VALUE | NUMBER | Hash value of the parent statement in the library cache. Two columns PARENT_HANDLE andHASH_VALUE can be used to join with V$SQLAREA to locate the parent cursor. |
SQL_ID | VARCHAR2(13) | SQL identifier of the parent statement in the library cache |
CHILD_NUMBER | NUMBER | Number of the child cursor that uses this work area. The columns PARENT_HANDLE , HASH_VALUE , andCHILD_NUMBER can be used to join with V$SQL to locate the child cursor using this area. |
WORKAREA_ADDRESS | RAW(4 | 8) | Address of the work area handle. This is the primary key for the view. |
OPERATION_TYPE | VARCHAR2(20) | Type of operation using the work area (SORT , HASH JOIN , GROUP BY , BUFFERING , BITMAP MERGE , orBITMAP CREATE ) |
OPERATION_ID | NUMBER | A unique number used to identify the operation in the execution plan. This identifier can be joined to V$SQL_PLAN to locate the operation that uses this work area. |
POLICY | VARCHAR2(10) | Sizing policy for this work area (MANUAL or AUTO ) |
ESTIMATED_OPTIMAL_SIZE | NUMBER | Estimated size (in bytes) required by this work area to execute the operation completely in memory (optimal execution). Derived from either optimizer statistics or previous executions. |
ESTIMATED_ONEPASS_SIZE | NUMBER | Estimated size (in bytes) required by this work area to execute the operation in a single pass. Derived from either optimizer statistics or previous executions. |
LAST_MEMORY_USED | NUMBER | Memory (in bytes) used by this work area during the last execution of the cursor |
LAST_EXECUTION | VARCHAR2(10) | Indicates whether this work area runs using OPTIMAL, ONE PASS , or ONE PASS memory requirement (or MULTI-PASS ), during the last execution of the cursor |
LAST_DEGREE | NUMBER | Degree of parallelism used during the last execution of this operation |
TOTAL_EXECUTIONS | NUMBER | Number of times this work area was active |
OPTIMAL_EXECUTIONS | NUMBER | Number of times this work area ran in optimal mode |
ONEPASS_EXECUTIONS | NUMBER | Number of times this work area ran in one-pass mode |
MULTIPASSES_EXECUTIONS | NUMBER | Number of times this work area ran below the one-pass memory requirement |
ACTIVE_TIME | NUMBER | Average time this work area is active (in hundredths of a second) |
MAX_TEMPSEG_SIZE | NUMBER | Maximum temporary segment size (in bytes) created by an instantiation of this work area. This column is NULL if this work area has never spilled to disk. |
LAST_TEMPSEG_SIZE | NUMBER | Temporary segment size (in bytes) created in the last instantiation of this work area. This column is NULL if the last instantiation of this work area did not spill to disk. |
7.5.1.2.6 V$SQL_WORKAREA
Oracle maintains cumulative work area statistics for each loaded cursor whose execution plan uses one or more work areas. Every time a work area is deallocated, theV$SQL_WORKAREA
table is updated with execution statistics for that work area.
V$SQL_WORKAREA
can be joined with V$SQL
to relate a work area to a cursor. It can even be joined to V$SQL_PLAN
to precisely determine which operator in the plan uses a work area.
Example 7-7 shows three typical queries on the V$SQL_WORKAREA
dynamic view:
Example 7-7 Querying V$SQL_WORKAREA
The following query finds the top 10 work areas requiring most cache memory:
SELECT * FROM ( SELECT workarea_address, operation_type, policy, estimated_optimal_size FROM V$SQL_WORKAREA ORDER BY estimated_optimal_size ) WHERE ROWNUM <= 10;
The following query finds the cursors with one or more work areas that have been executed in one or even multiple passes:
col sql_text format A80 wrap SELECT sql_text, sum(ONEPASS_EXECUTIONS) onepass_cnt, sum(MULTIPASSES_EXECUTIONS) mpass_cnt FROM V$SQL s, V$SQL_WORKAREA wa WHERE s.address = wa.address GROUP BY sql_text HAVING sum(ONEPASS_EXECUTIONS+MULTIPASSES_EXECUTIONS)>0;
Using the hash value and address of a particular cursor, the following query displays the cursor execution plan, including information about the associated work areas.
col "O/1/M" format a10 col name format a20 SELECT operation, options, object_name name, trunc(bytes/1024/1024) "input(MB)", trunc(last_memory_used/1024) last_mem, trunc(estimated_optimal_size/1024) optimal_mem, trunc(estimated_onepass_size/1024) onepass_mem, decode(optimal_executions, null, null, optimal_executions||'/'||onepass_executions||'/'|| multipasses_executions) "O/1/M" FROM V$SQL_PLAN p, V$SQL_WORKAREA w WHERE p.address=w.address(+) AND p.hash_value=w.hash_value(+) AND p.id=w.operation_id(+) AND p.address='88BB460C' AND p.hash_value=3738161960; OPERATION OPTIONS NAME input(MB) LAST_MEM OPTIMAL_ME ONEPASS_ME O/1/M ------------ -------- -------- --------- -------- ---------- ---------- ------ SELECT STATE HASH GROUP BY 4582 8 16 16 16/0/0 HASH JOIN SEMI 4582 5976 5194 2187 16/0/0 TABLE ACCESS FULL ORDERS 51 TABLE ACCESS FUL LINEITEM 1000
You can get the address and hash value from the V$SQL
view by specifying a pattern in the query. For example:
SELECT address, hash_value
FROM V$SQL
WHERE sql_text LIKE '%my_pattern%';
댓글 없음:
댓글 쓰기