Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2765579
  • 博文数量: 389
  • 博客积分: 4177
  • 博客等级: 上校
  • 技术积分: 4773
  • 用 户 组: 普通用户
  • 注册时间: 2008-11-16 23:29
文章分类

全部博文(389)

分类: Oracle

2016-07-07 22:45:35

                            Oracle 12C Big Table Cache特性

          在12.1.0.2之前,当进行全表扫描时,如果表的大小超过_small_table_threshold (块数)
的值时,oracle直接使用direct path read的方式.随着内存越来越大,如果继续使用这种方式那么就
不能有效利用内存.在之前的版本中,可以使用cache选项,但是使用cache选项会把表的所有块放到buffer
cache的MRU端,这样无形会造成buffer cache的泛洪,另外一个方法就是使用keep池,而keep池使用的
单独的一个池,基于lru和块级别的,如果keep池过小,会使部分块被移出去,而另外的一部分块则又
存在于keep池中。所有都有一定的局限性.

DONGDONGTANG> select a.ksppinm,b.ksppstvl,a.ksppdesc
  2  from x$ksppi a,x$ksppcv b
  3  where a.indx=b.indx
  4  and a.ksppinm like '\_small%' escape '\'
  5  ;
 
_small_table_threshold                                                           1205

创建一个对像,对像大的小超过_small_table_threshold所定义的大小

DONGDONGTANG> select blocks
  2  from cdb_tables
  3   where table_name='T1' and owner='FRANK';
 
    BLOCKS
----------
      3176

查看当前direct path read的计数

DONGDONGTANG> select name,value from v$sysstat where name like '%table scans (direct read)%';
 
NAME                                                                  VALUE
---------------------------------------------------------------- ----------
table scans (direct read)                                              3180

执行一次全表扫描
DONGDONGTANG> select sum(1) from frank.t1;

    SUM(1)
----------
    181872

DONGDONGTANG> select name,value from v$sysstat where name like '%table scans (direct read)%';
 
NAME                                                                  VALUE
---------------------------------------------------------------- ----------
table scans (direct read)                                              3181
 
由于该表被oracle认为是大表,因些使用了direct path read的方式来读取

刷新一下buffer cache

DONGDONGTANG> alter system flush buffer_cache;

System altered.

DONGDONGTANG> show sga;

Total System Global Area  851443712 bytes
Fixed Size    2930080 bytes
Variable Size  243272288 bytes
Database Buffers  599785472 bytes
Redo Buffers    5455872 bytes

设置Big Table Cache percent,该参数可以动态修改,当前修改为buffer cache的百分之20

DONGDONGTANG>  alter system set db_big_table_cache_percent_target=20;

System altered.

再次对表t1表做全表扫描
DONGDONGTANG> select sum(1) from frank.t1;

    SUM(1)
----------
    181872

DONGDONGTANG> select name,value from v$sysstat where name like '%table scans (direct read)%';
 
NAME                                                                  VALUE
---------------------------------------------------------------- ----------
table scans (direct read)                                              3181

发现direct path read的计数不再增加,这样就充分了说明oracle是从Big Table Cache读取数据块,而不是
再使用从磁盘读取的方式

DONGDONGTANG> select a.*,b.object_name from
  2  v$bt_scan_obj_temps a,cdb_objects b
  3   where a.DATAOBJ#=b.object_id
  4   and b.object_name='T1' and owner='FRANK';
 
       TS#   DATAOBJ# SIZE_IN_BLKS TEMPERATURE POLICY     CACHED_IN_MEM     CON_ID OBJECT_NAME
---------- ---------- ------------ ----------- ---------- ------------- ---------- --------------------------------------------------------------------------------
    196611      91793         3176        9000 MEM_ONLY            3176          0 T1

通过查询v$bt_scan_obj_temps发现,当前T1表已经被完全加载到Big Table Cache中了.后续的读取就不再从
磁盘上读取了.

   Big Table Cache和以前的keep池的特性非常相似,都是用来尽可能的保持重要的对像块在内存,而不影响其数据块
但是Big Table Cache是default buffer cache的一部分,使用是基于对像的,temperatuer的替换方式.

阅读(3795) | 评论(0) | 转发(0) |
0

上一篇: Oracle LGWR进程跟踪

下一篇:没有了

给主人留下些什么吧!~~