`

v$sql v$sqlarea v$sqltext v$sql_plan

 
阅读更多

v$sqltext
存储的是完整的SQL,SQL被分割

SQL> desc v$sqltext
Name                                      Null?    Type
----------------------------------------- -------- ----------------------------
ADDRESS                                            RAW(4)    ---------
HASH_VALUE                                         NUMBER   ---------  和 address 一起唯一标志一条sql
COMMAND_TYPE                                       NUMBER
PIECE                                              NUMBER   ----------  分片之后的顺序编号
SQL_TEXT                                           VARCHAR2(64)   --------------  注意长度

 

v$sqlarea   ---------  存储的SQL 和一些相关的信息,比如累计的执行次数,逻辑读,物理读等统计信息
SQL> desc v$sqlarea
Name                                      Null?    Type
----------------------------------------- -------- ----------------------------
SQL_TEXT                                           VARCHAR2(1000)
SHARABLE_MEM                                       NUMBER
PERSISTENT_MEM                                     NUMBER
RUNTIME_MEM                                        NUMBER
SORTS                                              NUMBER
VERSION_COUNT                                      NUMBER
LOADED_VERSIONS                                    NUMBER
OPEN_VERSIONS                                      NUMBER
USERS_OPENING                                      NUMBER
FETCHES                                            NUMBER
EXECUTIONS                                         NUMBER
USERS_EXECUTING                                    NUMBER
LOADS                                              NUMBER
FIRST_LOAD_TIME                                    VARCHAR2(38)
INVALIDATIONS                                      NUMBER
PARSE_CALLS                                        NUMBER
DISK_READS                                         NUMBER
BUFFER_GETS                                        NUMBER
ROWS_PROCESSED                                     NUMBER
COMMAND_TYPE                                       NUMBER
OPTIMIZER_MODE                                     VARCHAR2(25)
PARSING_USER_ID                                    NUMBER
PARSING_SCHEMA_ID                                  NUMBER
KEPT_VERSIONS                                      NUMBER
ADDRESS                                            RAW(4)
HASH_VALUE                                         NUMBER
MODULE                                             VARCHAR2(64)
MODULE_HASH                                        NUMBER
ACTION                                             VARCHAR2(64)
ACTION_HASH                                        NUMBER
SERIALIZABLE_ABORTS                                NUMBER
CPU_TIME                                           NUMBER
ELAPSED_TIME                                       NUMBER
IS_OBSOLETE                                        VARCHAR2(1)
CHILD_LATCH                                        NUMBER

 


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


SQL> desc v$sql
Name                                      Null?    Type
----------------------------------------- -------- ----------------------------
SQL_TEXT                                           VARCHAR2(1000)
SHARABLE_MEM                                       NUMBER
PERSISTENT_MEM                                     NUMBER
RUNTIME_MEM                                        NUMBER
SORTS                                              NUMBER
LOADED_VERSIONS                                    NUMBER
OPEN_VERSIONS                                      NUMBER
USERS_OPENING                                      NUMBER
FETCHES                                            NUMBER
EXECUTIONS                                         NUMBER
USERS_EXECUTING                                    NUMBER
LOADS                                              NUMBER
FIRST_LOAD_TIME                                    VARCHAR2(38)
INVALIDATIONS                                      NUMBER
PARSE_CALLS                                        NUMBER
DISK_READS                                         NUMBER
BUFFER_GETS                                        NUMBER
ROWS_PROCESSED                                     NUMBER
COMMAND_TYPE                                       NUMBER
OPTIMIZER_MODE                                     VARCHAR2(10)
OPTIMIZER_COST                                     NUMBER
PARSING_USER_ID                                    NUMBER
PARSING_SCHEMA_ID                                  NUMBER
KEPT_VERSIONS                                      NUMBER
ADDRESS                                            RAW(4)
TYPE_CHK_HEAP                                      RAW(4)
HASH_VALUE                                         NUMBER
PLAN_HASH_VALUE                                    NUMBER
CHILD_NUMBER                                       NUMBER    ----------  注意这个 
MODULE                                             VARCHAR2(64)
MODULE_HASH                                        NUMBER
ACTION                                             VARCHAR2(64)
ACTION_HASH                                        NUMBER
SERIALIZABLE_ABORTS                                NUMBER
OUTLINE_CATEGORY                                   VARCHAR2(64)
CPU_TIME                                           NUMBER
ELAPSED_TIME                                       NUMBER
OUTLINE_SID                                        NUMBER    --------------  注意这里跟 outline 有关
CHILD_ADDRESS                                      RAW(4)
SQLTYPE                                            NUMBER
REMOTE                                             VARCHAR2(1)
OBJECT_STATUS                                      VARCHAR2(19)
LITERAL_HASH_VALUE                                 NUMBER
LAST_LOAD_TIME                                     VARCHAR2(38)
IS_OBSOLETE                                        VARCHAR2(1)
CHILD_LATCH                                        NUMBER


另外注意这个
QL> desc v$sql_plan
Name                                      Null?    Type
----------------------------------------- -------- ----------------------------
ADDRESS                                            RAW(4)
HASH_VALUE                                         NUMBER
CHILD_NUMBER                                       NUMBER   ------------   注意这个和 v$sql 里面的相同字段
OPERATION                                          VARCHAR2(60)
OPTIONS                                            VARCHAR2(60)
OBJECT_NODE                                        VARCHAR2(20)
OBJECT#                                            NUMBER
OBJECT_OWNER                                       VARCHAR2(30)
OBJECT_NAME                                        VARCHAR2(64)
OPTIMIZER                                          VARCHAR2(40)
ID                                                 NUMBER
PARENT_ID                                          NUMBER
DEPTH                                              NUMBER
POSITION                                           NUMBER
SEARCH_COLUMNS                                     NUMBER
COST                                               NUMBER
CARDINALITY                                        NUMBER
BYTES                                              NUMBER
OTHER_TAG                                          VARCHAR2(70)
PARTITION_START                                    VARCHAR2(10)
PARTITION_STOP                                     VARCHAR2(10)
PARTITION_ID                                       NUMBER
OTHER                                              VARCHAR2(4000)
DISTRIBUTION                                       VARCHAR2(40)
CPU_COST                                           NUMBER
IO_COST                                            NUMBER
TEMP_SPACE                                         NUMBER
ACCESS_PREDICATES                                  VARCHAR2(4000)
FILTER_PREDICATES                                  VARCHAR2(4000)


实际上,看起来同样的一句SQL ,往往具有不同的执行计划
如果是不同的数据库用户,那么相应的涉及的 对象 可能都不一样,注意v$sql 中
OBJECT#                                            NUMBER
OBJECT_OWNER                                       VARCHAR2(30)
OBJECT_NAME                                        VARCHAR2(64)
OPTIMIZER                                          VARCHAR2(40)

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

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

ADDRESS                                            RAW(4)
HASH_VALUE                                         NUMBER
CHILD_NUMBER                                       NUMBER


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

分享到:
评论

相关推荐

    oracle_V$SQLAREA_.rar_oracle_oracle V$sqlarea

    标题中的"oracle_V$SQLAREA_.rar_oracle_oracle V$sqlarea"暗示了这是一个关于`V$SQLAREA`视图的资源压缩包,可能包含了相关查询和解释的文本文件。 `V$SQLAREA`视图包含的数据涵盖了SQL语句的多个方面,如: 1. *...

    学些动态性能表-word版

    学习动态性能表(四)--v$sqltext&v$sqlarea 学习动态性能表(五)--v$session 学习动态性能表(六)--v$session_wait&v$session_event 学习动态性能表(七)--v$process 学习动态性能表(八)--v$lock&v$locked_object ...

    SQL优化器相关知识 精品资料.pptx

    V$SQL、V$SQLAREA、V$SQLTEXT视图可以提供SQL语句的执行计划信息,例如: 1. V$SQL视图:提供SQL语句的执行计划信息,包括执行计划的详细信息和执行统计信息。 2. V$SQLAREA视图:提供SQL语句的执行计划信息,包括...

    SQL优化器相关知识.pptx

    - v$sql家族视图:如v$sql、v$sqlarea、v$sqltext等,它们用于查看缓存在Library Cache中的SQL执行计划和统计信息。v$sql_plan、v$sql_plan_statistics以及v$sql_plan_statistics_all提供更多详细的执行计划和统计...

    学习Oracle动态性能表

    10. **v$sqltext&v$sqlarea**:这两个视图与v$sql相关,但更专注于SQL语句的实际文本和内存分配情况,对理解和优化SQL执行很有帮助。 通过对这些动态性能表的深入学习,数据库管理员能够更好地监控Oracle数据库的...

    定位Oracle中的topsql[总结].pdf

    可以通过查询 V$SQLAREA 视图,按照 buffer_gets 和 disk_reads 两个字段排序,找到资源消耗最大的 SQL 语句。 ```sql SELECT b.username username, a.sql_id, a.executions exec, a.buffer_gets buffer, ...

    oracle动态链接表

    * V$SQLAREA 表提供了 Shared pool 中 cursor 的信息,包括 cursor 的执行次数、执行时间等。 * 该表可以帮助 DBA 了解 Shared pool 中 cursor 的使用情况。 7. V$SESSION 表:提供了当前会话的信息。 * V$...

    20个常用的动态性能视图

    4. **v$sqltext & v$sqlarea**:v$sqltext用于获取SQL语句的文本内容,而v$sqlarea则包含了SQL语句的执行上下文信息,包括执行次数、CPU时间、共享池使用情况等。 5. **v$session**:这个视图显示了当前所有活跃...

    如何监控Oracle索引的使用完全解析

    监控索引使用的一个实例脚本在Oracle 8i中可以这样编写,但需要注意,这个脚本有一定的前提条件,如解释所有v$sqlarea中的SQL权限,计划表的 Remarks字段用于错误检测,假设所有SQL的OPTIMIZER_GOAL是常量,统计信息...

    Oracle数据库日常管理方案精.docx

    FROM v$sqlarea ORDER BY disk_reads DESC) WHERE ROWNUM ; ``` 这段SQL用于查找执行次数多且磁盘读取量大的SQL语句,帮助管理员定位性能瓶颈。 ##### 3.2 查询有enqueue等待的事件 ```sql SELECT b.SID, b....

    SQL 学习4

    比如,`V$SQL`视图记录了所有已解析的SQL语句,`V$SESSION_LONGOPS`视图展示了当前长时间运行的操作,而`V$SQLAREA`和`V$SQLTEXT`可以提供SQL语句的详细信息。此外,`DBA_HIST_SQLTEXT`和`DBA_HIST_SQLSTAT`等历史...

    DBA笔试考题.txt

    - 使用`V$SQLTEXT`和`V$SESSION`视图来查看指定会话的SQL语句: ```sql COLUMN SQL FORMAT A200; SELECT machine, sql_text AS SQL FROM v$sqltext a, v$session b WHERE address = sql_address AND machine =...

Global site tag (gtag.js) - Google Analytics