zoukankan      html  css  js  c++  java
  • v$db_object_cache

    官方文档上面说 V$DB_OBJECT_CACHE displays database objects that are cached in the library cache.
    下面做个试验:
    session a:
    SQL> startup
    ORACLE 例程已经启动。
    Total System Global Area  104857600 bytes
    Fixed Size                  1289172 bytes
    Variable Size              71304236 bytes
    Database Buffers           25165824 bytes
    Redo Buffers                7098368 bytes
    数据库装载完毕。
    数据库已经打开。
    session b:
    SQL> select count(*) from test2;
      COUNT(*)
    ----------
             0
    session a:
    SQL> col name format a30
    SQL> select name,executions,pins,kept,sharable_mem from v$db_object_cache where name='select count(*) from test2';
    NAME                           EXECUTIONS       PINS KEP SHARABLE_MEM
    ------------------------------ ---------- ---------- --- ------------
    select count(*) from test2              1          0 NO          7480
    select count(*) from test2              0          0 NO          1436
    session b:
    SQL> /
      COUNT(*)
    ----------
             0
    session a:
    SQL> select name,executions,pins,kept,sharable_mem from v$db_object_cache where name='select count(*) from test2';
    NAME                           EXECUTIONS       PINS KEP SHARABLE_MEM
    ------------------------------ ---------- ---------- --- ------------
    select count(*) from test2              2          0 NO          7480
    select count(*) from test2              0          0 NO          1436
    SQL> select sql_text,executions,version_count from v$sqlarea where sql_text='select count(*) from test2';
    SQL_TEXT                       EXECUTIONS VERSION_COUNT
    ------------------------------ ---------- -------------
    select count(*) from test2              2             1
    session b:
    SQL> alter session set optimizer_mode=rule;
    会话已更改。
    SQL> select count(*) from test2;
      COUNT(*)
    ----------
             0
    session a:
    SQL> select name,executions,pins,kept,sharable_mem from v$db_object_cache where name='select count(*) from test2';
    NAME                           EXECUTIONS       PINS KEP SHARABLE_MEM
    ------------------------------ ---------- ---------- --- ------------
    select count(*) from test2              2          0 NO          7480
    select count(*) from test2              1          0 NO          7480
    select count(*) from test2              0          0 NO          1436
    SQL> select sql_text,executions,version_count from v$sqlarea where sql_text='select count(*) from test2';
    SQL_TEXT                       EXECUTIONS VERSION_COUNT
    ------------------------------ ---------- -------------
    select count(*) from test2              3             2
    注意观察红色部分,为什么一条SQL执行了会在v$db_object_cache中记录从来不执行(executions=0)的信息呢?在pub上面看见有人说这个是一个cusor的parent,
    我也赞同此观点。另外从上面的实验可以看出,一条SQL的child cursor 越多,越耗资源,还可以看出version_count=所有child cursor之和。
    关于v$db_object_cache的脚本放在 userful script里面,这里不再贴出。

  • 相关阅读:
    线程池中shutdown()和shutdownNow()方法的区别
    java.util.concurrent.TimeoutException: Idle timeout expired: 300000/300000 ms
    ConnectTimeout和ReadTimeout所代表的意义
    hive 查询注意问题
    java面试题之int和Integer的区别
    MySQL中KEY、PRIMARY KEY、UNIQUE KEY、INDEX 的区别
    MySQL数据库使用mysqldump导出数据详解
    C++宏定义详解
    OTL调用存储过程/函数及注意事项
    linux自定义开机启动服务和chkconfig使用方法
  • 原文地址:https://www.cnblogs.com/hehe520/p/6330641.html
Copyright © 2011-2022 走看看