v$sql,v$sqlarea,v$sqltext 和 v$sql_plan 说明

. 先看官网对这几个视图的说明(ORACLE 11gR2

1.1 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 the DBMS_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 SERVICEcolumn

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:

· VALID - Valid, authorized without errors

· VALID_AUTH_ERROR - Valid, authorized with authorization errors

· VALID_COMPILE_ERROR - Valid, authorized with compilation errors

· VALID_UNAUTH - Valid, unauthorized

· INVALID_UNAUTH - Invalid, unauthorized

· INVALID - Invalid, unauthorized but keep the timestamp

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. If CURSOR_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

Typecheck memory

IO_CELL_OFFLOAD_ELIGIBLE_BYTES

NUMBER

Number of I/O bytes which can be filtered by the Exadata storage system

See Also: Oracle Exadata Storage Server Software documentation for more information

IO_INTERCONNECT_BYTES

NUMBER

Number of I/O bytes exchanged between Oracle Database and the storage system

PHYSICAL_READ_REQUESTS

NUMBER

Number of physical read I/O requests issued by the monitored SQL

PHYSICAL_READ_BYTES

NUMBER

Number of bytes read from disks by the monitored SQL

PHYSICAL_WRITE_REQUESTS

NUMBER

Number of physical write I/O requests issued by the monitored SQL

PHYSICAL_WRITE_BYTES

NUMBER

Number of bytes written to disks by the monitored SQL

OPTIMIZED_PHY_READ_REQUESTS

NUMBER

Number of physical read I/O requests from Database Smart Flash Cache issued by the monitored SQL

LOCKED_TOTAL

NUMBER

Total number of times the child cursor has been locked

PINNED_TOTAL

NUMBER

Total number of times the child cursor has been pinned

IO_CELL_UNCOMPRESSED_BYTES

NUMBER

Number of uncompressed bytes (that is, size after decompression) that are offloaded to the Exadata cells

See Also: Oracle Exadata Storage Server Software documentation for more information

IO_CELL_OFFLOAD_RETURNED_BYTES

NUMBER

Number of bytes that are returned by the Exadata cell for smart scan only (that is, not including bytes for other database I/O)

See Also: Oracle Exadata Storage Server Software documentation for more information

1.2 V$SQLAREA

V$SQLAREA displays statistics on shared SQL areas and contains one row per SQL string. It provides statistics on SQL statements that are in memory, parsed, and ready for execution.

Column

Datatype

Description

SQL_TEXT

VARCHAR2(1000)

First thousand characters of the SQL text for the current cursor

SQL_FULLTEXT

CLOB

All 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 lifetime of an open cursor. If multiple child cursors exist, then the fixed sum of memory used for the lifetime of all the child cursors.

RUNTIME_MEM

NUMBER

Fixed amount of memory required during execution of a cursor. If multiple child cursors exist, then 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 loaded

OPEN_VERSIONS

NUMBER

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

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

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 calls to 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 (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 processed on behalf of this SQL statement

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 that has parsed the very first cursor under this parent

PARSING_SCHEMA_ID

NUMBER

Schema ID that was used to parse this child cursor

PARSING_SCHEMA_NAME

VARCHAR2(30)

Schema name that was used to parse this child cursor

KEPT_VERSIONS

NUMBER

Number of child cursors that have been marked to be kept using the DBMS_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

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).

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 calling DBMS_APPLICATION_INFO.SET_MODULE

MODULE_HASH

NUMBER

Hash value of the module that is named 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 as set by calling DBMS_APPLICATION_INFO.SET_ACTION

ACTION_HASH

NUMBER

Hash value of the action that is named in the ACTION column

SERIALIZABLE_ABORTS

NUMBER

Number of times the transaction failed to serialize, producing ORA-08177 errors, totalled over all the child cursors

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

VARCHAR2(40)

Outline session identifier

LAST_ACTIVE_CHILD_ADDRESS

RAW(4 | 8)

Address (identifier) of the child cursor that was the last to be active in the group (that is, the child cursor on behalf of which statistics in V$SQL were updated)

REMOTE

VARCHAR2(1)

Indicates whether the cursor is remote mapped (Y) or not (N)

OBJECT_STATUS

VARCHAR2(19)

Status of the cursor:

· VALID - Valid, authorized without errors

· VALID_AUTH_ERROR - Valid, authorized with authorization errors

· VALID_COMPILE_ERROR - Valid, authorized with compilation errors

· VALID_UNAUTH - Valid, unauthorized

· INVALID_UNAUTH - Invalid, unauthorized

· INVALID - Invalid, unauthorized but keep the timestamp

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. If CURSOR_SHARING is not used, then the value is 0.

LAST_LOAD_TIME

DATE

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.

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 used when the CURSOR_SHARING parameter is set to EXACT

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

Typecheck memory

IO_CELL_OFFLOAD_ELIGIBLE_BYTES

NUMBER

Number of I/O bytes which can be filtered by the Exadata storage system

See Also: Oracle Exadata Storage Server Software documentation for more information

IO_INTERCONNECT_BYTES

NUMBER

Number of I/O bytes exchanged between Oracle Database and the storage system

PHYSICAL_READ_REQUESTS

NUMBER

Number of physical read I/O requests issued by the monitored SQL

PHYSICAL_READ_BYTES

NUMBER

Number of bytes read from disks by the monitored SQL

PHYSICAL_WRITE_REQUESTS

NUMBER

Number of physical write I/O requests issued by the monitored SQL

PHYSICAL_WRITE_BYTES

NUMBER

Number of bytes written to disks by the monitored SQL

OPTIMIZED_PHY_READ_REQUESTS

NUMBER

Number of physical read I/O requests from Database Smart Flash Cache issued by the monitored SQL

LOCKED_TOTAL

NUMBER

Total number of times the child cursor has been locked

PINNED_TOTAL

NUMBER

Total number of times the child cursor has been pinned

IO_CELL_UNCOMPRESSED_BYTES

NUMBER

Number of uncompressed bytes (that is, size after decompression) that are offloaded to the Exadata cells

See Also: Oracle Exadata Storage Server Software documentation for more information

IO_CELL_OFFLOAD_RETURNED_BYTES

NUMBER

Number of bytes that are returned by the Exadata cell for smart scan only (that is, not including bytes for other database I/O)

See Also: Oracle Exadata Storage Server Software documentation for more information

1.3 V$SQLTEXT

V$SQLTEXT displays the text of SQL statements belonging to shared SQL cursors in the SGA.

Column

Datatype

Description

ADDRESS

RAW(4 | 8)

Used with HASH_VALUE to uniquely identify a cached cursor

HASH_VALUE

NUMBER

Used with ADDRESS to uniquely identify a cached cursor

SQL_ID

VARCHAR2(13)

SQL identifier of a cached cursor

COMMAND_TYPE

NUMBER

Code for the type of SQL statement (SELECT, INSERT, and so on)

PIECE

NUMBER

Number used to order the pieces of SQL text

SQL_TEXT

VARCHAR2(64)

A column containing one piece of the SQL text

1.4 V$SQL_PLAN

V$SQL_PLAN contains the execution plan information for each child cursor loaded in the library cache.

Column

Datatype

Description

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. The two columns ADDRESS and HASH_VALUE can be used to join with V$SQLAREA to add the cursor-specific information.

SQL_ID

VARCHAR2(13)

SQL identifier of the parent cursor in the library cache

PLAN_HASH_VALUE

NUMBER

Numerical representation of the SQL plan for the 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_ADDRESS

RAW(4 | 8)

Address of the child cursor

CHILD_NUMBER

NUMBER

Number of the child cursor that uses this execution plan. The columns ADDRESS, HASH_VALUE, and CHILD_NUMBER can be used to join with V$SQL to add the child cursor-specific information.

TIMESTAMP

DATE

Date and time when the execution plan was generated

OPERATION

VARCHAR2(30)

Name of the internal operation performed in this step (for example, TABLE ACCESS)

OPTIONS

VARCHAR2(30)

A variation on the operation described in the OPERATION column (for example, FULL)

OBJECT_NODE

VARCHAR2(40)

Name of the database link used to reference the object (a table name or view name). For local queries that use parallel execution, this column describes the order in which output from operations is consumed.

OBJECT#

NUMBER

Object number of the table or the index

OBJECT_OWNER

VARCHAR2(30)

Name of the user who owns the schema containing the table or index

OBJECT_NAME

VARCHAR2(30)

Name of the table or index

OBJECT_ALIAS

VARCHAR2(65)

Alias for the object

OBJECT_TYPE

VARCHAR2(20)

Type of the object

OPTIMIZER

VARCHAR2(20)

Current mode of the optimizer for the first row in the plan (statement line), for example, CHOOSE. When the operation is a database access (for example, TABLE ACCESS), this column indicates whether or not the object is analyzed.

ID

NUMBER

A number assigned to each step in the execution plan

PARENT_ID

NUMBER

ID of the next execution step that operates on the output of the current step

DEPTH

NUMBER

Depth (or level) of the operation in the tree. It is not necessary to issue a CONNECT BY statement to get the level information, which is generally used to indent the rows from the PLAN_TABLE table. The root operation (statement) is level 0.

POSITION

NUMBER

Order of processing for all operations that have the same PARENT_ID

SEARCH_COLUMNS

NUMBER

Number of index columns with start and stop keys (that is, the number of columns with matching predicates)

COST

NUMBER

Cost of the operation as estimated by the optimizer's cost-based approach. For statements that use the rule-based approach, this column is null.

CARDINALITY

NUMBER

Estimate, by the cost-based optimizer, of the number of rows produced by the operation

BYTES

NUMBER

Estimate, by the cost-based optimizer, of the number of bytes produced by the operation

OTHER_TAG

VARCHAR2(35)

Describes the contents of the OTHER column. See EXPLAIN PLAN for values.

PARTITION_START

VARCHAR2(64)

Start partition of a range of accessed partitions

PARTITION_STOP

VARCHAR2(64)

Stop partition of a range of accessed partitions

PARTITION_ID

NUMBER

Step that computes the pair of values of the PARTITION_START and PARTITION_STOP columns

OTHER

VARCHAR2(4000)

Other information specific to the execution step that users may find useful. See EXPLAIN PLAN for values.

DISTRIBUTION

VARCHAR2(20)

Stores the method used to distribute rows from producer query servers to consumer query servers

CPU_COST

NUMBER

CPU cost of the operation as estimated by the optimizer's cost-based approach. For statements that use the rule-based approach, this column is null.

IO_COST

NUMBER

I/O cost of the operation as estimated by the optimizer's cost-based approach. For statements that use the rule-based approach, this column is null.

TEMP_SPACE

NUMBER

Temporary space usage of the operation (sort or hash-join) as estimated by the optimizer's cost-based approach. For statements that use the rule-based approach, this column is null.

ACCESS_PREDICATES

VARCHAR2(4000)

Predicates used to locate rows in an access structure. For example, start or stop predicates for an index range scan.

FILTER_PREDICATES

VARCHAR2(4000)

Predicates used to filter rows before producing them

PROJECTION

VARCHAR2(4000)

Expressions produced by the operation

TIME

NUMBER

Elapsed time (in seconds) of the operation as estimated by the optimizer's cost-based approach. For statements that use the rule-based approach, this column is null.

QBLOCK_NAME

VARCHAR2(30)

Name of the query block

REMARKS

VARCHAR2(4000)

Remarks

OTHER_XML

CLOB

Provides extra information specific to an execution step of the execution plan. The content of this column is structured using XML since multiple pieces of information can be stored there. This includes:

· Name of the schema against which the query was parsed

· Release number of the Oracle Database that produced the explain plan

· Hash value associated with the execution plan

· Name (if any) of the outline or the SQL profile used to build the execution plan

· Indication of whether or not dynamic sampling was used to produce the plan

· The outline data, a set of optimizer hints that can be used to regenerate the same plan

. 查看GV$ 视图的定义语句

/* Formatted on 2011/1/10 15:54:44 (QP5 v5.115.810.9015) */

SELECT view_definition

FROM v$fixed_view_definition

WHERE view_name = 'GV$SQL';

可以使用上面的语句查询视图的定义语句。 这里查询的是GV$, 因为V$视图也是根据GV$出来的。 这个可以用上面的语句查询下V$SQL 就可以验证了。

GV$SQL的定义如下:

/* Formatted on 2011/1/10 16:08:04 (QP5 v5.115.810.9015) */

SELECT inst_id,kglnaobj,kglfnobj,kglobt03,kglobhs0

+ kglobhs1

+ kglobhs2

+ kglobhs3

+ kglobhs4

+ kglobhs5

+ kglobhs6

+ kglobt16,

kglobt08 + kglobt11,

kglobt10,

kglobt01,

DECODE (kglobhs6, 0, 0, 1),

DECODE (kglhdlmd, 0, 0, 1),

kglhdlkc,kglobt04,kglobt05,kglobt48, kglobt35,kglobpc6,kglhdldc,

SUBSTR (TO_CHAR (kglnatim, 'YYYY-MM-DD/HH24:MI:SS'), 1, 19),

kglhdivc, kglobt12, kglobt13, kglobwdw,

kglobt14, kglobwap, kglobwcc, kglobwcl,

kglobwui, kglobt42, kglobt43, kglobt15,

kglobt02,

DECODE (kglobt32, 0, 'NONE', 1, 'ALL_ROWS', 2, 'FIRST_ROWS',

3, 'RULE', 4, 'CHOOSE', 'UNKNOWN'),

kglobtn0, kglobcce, kglobcceh, kglobt17,

kglobt18, kglobts4, kglhdkmk, kglhdpar,

kglobtp0, kglnahsh, kglobt46, kglobt30,

kglobt09, kglobts5, kglobt48, kglobts0,

kglobt19, kglobts1, kglobt20, kglobt21,

kglobts2, kglobt06, kglobt07,

DECODE (kglobt28, 0, TO_NUMBER (NULL), kglobt28),

kglhdadr, kglobt29, DECODE (BITAND (kglobt00, 64), 64, 'Y', 'N'),

DECODE (kglobsta, 1, 'VALID', 2, 'VALID_AUTH_ERROR',

3, 'VALID_COMPILE_ERROR', 4, 'VALID_UNAUTH',

5, 'INVALID_UNAUTH', 6, 'INVALID'),

kglobt31,

SUBSTR (TO_CHAR (kglobtt0, 'YYYY-MM-DD/HH24:MI:SS'), 1, 19),

DECODE (kglobt33, 1, 'Y', 'N'),

DECODE (BITAND (kglobacs, 1), 1, 'Y', 'N'),

DECODE (BITAND (kglobacs, 2), 2, 'Y', 'N'),

DECODE (BITAND (kglobacs, 4), 4, 'Y', 'N'),

kglhdclt, kglobts3, kglobts7, kglobts6,

kglobt44, kglobt45, kglobt47, kglobt49,

kglobcla, kglobcbca, kglobt22, kglobt52,

kglobt53, kglobt54,kglobt55, kglobt56,

kglobt57, kglobt58, kglobt23, kglobt24,

kglobt59, kglobt53 - ( (kglobt55 + kglobt57) - kglobt52)

FROM x$kglcursor_child

GV$SQLTEXT 定义如下:

SELECT inst_id,

kglhdadr,

kglnahsh,

kglnasqlid,

kgloboct,

piece,

name

FROM x$kglna

WHERE kgloboct != 0

GV$SQLAREA 定义

/* Formatted on 2011/1/10 16:05:52 (QP5 v5.115.810.9015) */

SELECT inst_id, kglnaobj, kglfnobj, kglobt03,

kglobhs0 + kglobhs1 + kglobhs2 + kglobhs3

+ kglobhs4 + kglobhs5 + kglobhs6,

kglobt08 + kglobt11, kglobt10, kglobt01,

kglobccc, kglobclc, kglhdlmd, kglhdlkc,

kglobt04, kglobt05, kglobt48, kglobt35,

kglobpc6, kglhdldc,

SUBSTR (TO_CHAR (kglnatim, 'YYYY-MM-DD/HH24:MI:SS'), 1, 19),

kglhdivc, kglobt12, kglobt13, kglobwdw,

kglobt14, kglobwap, kglobwcc, kglobwcl,

kglobwui, kglobt42, kglobt43, kglobt15,

kglobt02,

DECODE (kglobt32, 0, 'NONE', 1, 'ALL_ROWS', 2, 'FIRST_ROWS',

3, 'RULE', 4, 'CHOOSE', 'UNKNOWN'),

kglobtn0, kglobcce, kglobcceh, kglobt17,

kglobt18, kglobts4, kglhdkmk, kglhdpar,

kglna hsh, kglobt46, kglobt30, kglobts0,

kglobt19, kglobts1, kglobt20, kglobt21,

kglobts2, kglobt06, kglobt07,

DECODE (kglobt28, 0, NULL, kglobt28),kglhdadr,

DECODE (BITAND (kglobt00, 64), 64, 'Y', 'N'),

DECODE (kglobsta, 1, 'VALID', 2, 'VALID_AUTH_ERROR', 3,

'VALID_COMPILE_ERROR',4, 'VALID_UNAUTH',5,

'INVALID_UNAUTH',6, 'INVALID'), kglobt31,kglobtt0,

DECODE (kglobt33, 1, 'Y', 'N'),

DECODE (BITAND (kglobacs, 1), 1, 'Y', 'N'),

DECODE (BITAND (kglobacs, 2), 2, 'Y', 'N'),

kglhdclt,kglobts3,kglobts7,kglobts6,

kglobt44,kglobt45,kglobt47,kglobt49,

kglobcla,kglobcbca,kglobt22,kglobt52,

kglobt53,kglobt54,kglobt55,kglobt56,

kglobt57, kglobt58, kglobt23,kglobt24,

kglobt59, kglobt53 - ( (kglobt55 + kglobt57) - kglobt52)

FROM x$kglcursor_child_sqlid

WHERE kglobt02 != 0

从上面的语句可以看出,这些视图都是根据x$视图来定义的。 对于X$视图,在我以前的Blog里有说明:

Oracle 动态性能视图

http://blog.csdn.net/tianlesoftware/archive/2010/09/04/5863191.aspx

在这篇blog1.2节中对X$介绍:1.2 V$, V_$, GV$, X$ 视图说明

X$表包含了特定实例的各方面的信息,是Oracle数据库的运行基础,如当前的配置信息,连接到实例的会话,以及丰富而有价值的性能信息。 X$表并不是驻留在数据库文件的永久表或临时表。X$表仅仅驻留在内存中,当实例启动时,由Oracle应用程序动态创建,在内存中进行实时的维护。 它们中的大多数至少需要装载或已经打开的数据库。X$表为SYS用户所拥有,并且是只读的。 不能进行DML(更新,插入,删除)X$表对数据库来说至关重要,所以Oracle不允许SYSDBA之外的用户直接访问,显示授权不被允许。

V$SQLTEXT:存储的是完整的SQL, 但是SQL是被分割。

V$SQLAREA:存储的SQL 和一些相关的信息,比如累计的执行次数,逻辑读,物理读等统计信息。

V$SQL存储的是具体的SQL 和执行计划相关信息,实际上,v$sqlarea 可以看做 v$sql 根据 sqltext 做了 group by 之后的信息。

v$sqltext中有内存中完整的sql语句,而其他两个视图都是部分sql语句;

v$sqltext中没有该语句的统计信息,比如执行次数等。

这几个视图的小应用:

Oracle 实时查询最耗CPU资源的SQL语句

http://blog.csdn.net/tianlesoftware/archive/2009/11/30/4898607.aspx

. v$sql, v$sql_plan 与执行计划

有关执行计划的东西,参考我的Blog

Oracle Explain Plan

http://blog.csdn.net/tianlesoftware/archive/2010/08/20/5827245.aspx

Oracle Optimizer CBO RBO

http://blog.csdn.net/tianlesoftware/archive/2010/08/19/5824886.aspx

实际上,看起来同样的一句SQL ,往往具有不同的执行计划, 如果是不同的数据库用户,那么相应的涉及的 对象 可能都不一样,如v$sql_plan下的:

HASH_VALUE

NUMBER

Hash value of the parent statement in the library cache. The two columns ADDRESS and HASH_VALUE can be used to join with V$SQLAREA to add the cursor-specific information.

OBJECT#

NUMBER

Object number of the table or the index

OBJECT_OWNER

VARCHAR2(30)

Name of the user who owns the schema containing the table or index

OBJECT_NAME

VARCHAR2(30)

Name of the table or index

OPTIMIZER

VARCHAR2(20)

Current mode of the optimizer for the first row in the plan (statement line), for example, CHOOSE. When the operation is a database access (for example, TABLE ACCESS), this column indicates whether or not the object is analyzed.

即使是相同的数据库用户,若 session 的优化模式、session 级的参数 等不一样,执行计划也能不同。所以即使相同的sql,也可能具有不同的执行计划。

v$sql v$sql_plan就代表了具体的sql的执行计划,他们通过下面3个字段做连接:

ADDRESS RAW(4)

HASH_VALUE NUMBER

CHILD_NUMBER NUMBER

V$SQLAREA 忽略了执行计划 等差异,只是在形式上sql文本看起来一样。相当于做了个聚合,是多个不同执行计划的sql的聚合和累计信息。

------------------------------------------------------------------------------

Blog http://blog.csdn.net/tianlesoftware

网上资源: http://tianlesoftware.download.csdn.net

相关视频:http://blog.csdn.net/tianlesoftware/archive/2009/11/27/4886500.aspx

DBA1 群:62697716(); DBA2 群:62697977()

DBA3 群:62697850 DBA 超级群:63306533;

聊天 群:40132017

--加群需要在备注说明Oracle表空间和数据文件的关系,否则拒绝申请

你可能感兴趣的:(text)