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的聚合和累计信息

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值