开博了。其实之前有的,只是不在pub上,最近实在忍受不了msn共享空间了。

关于Multiple Buffer Pools的一些疑问

上一篇 / 下一篇  2008-06-24 10:22:42 / 个人分类:Oracle资料与实践

查看( 155 ) / 评论( 5 )
Oracle7.3之后,oracle允许在段创建的时候指定buffer pool,分别可以指定DEFAULT,KEEP,RECYCLE,如果不指定,默认为DEFAULT
我们可以通过下面的方法修改表或者索引的buffer pool:

1、查看表所对应的buffer
可以用两种方法查看:
set long 10000
select dbms_metadata.get_ddl('TABLE','&tname') from dual;

select table_name ,buffer_pool from dba_tables where table_name ='TEST';

2、查看可以被放入keep池的表
小表经常被访问,需要设置DB_KEEP_CACHE_SIZE,独立于db_cache_size
SELECT o.owner, object_name, object_type, COUNT(1) buffers
FROM SYS.x$bh, dba_objects o
WHERE tch > 10
AND lru_flag = 8
AND obj = o.object_id
AND o.owner not in ('SYSTEM','SYS')
GROUP BY o.owner, object_name, object_type
ORDER BY buffers;

----修改对象定义
alter table t storage(buffer_pool keep);

alter index test.BM_IDX_BT storage(buffer_pool KEEP);

3、查看可以被放入recycle池的表
用于不经常访问的大segment,不希望其保留在内存中,需要设置DB_RECYCLE_CACHE_SIZE,独立于db_cache_size
Col object_name format a30
Col object_type format a20
SELECT o.owner, object_name, object_type, COUNT(1) buffers
FROM SYS.x$bh, dba_objects o
WHERE (tch = 1 OR (tch = 0 AND lru_flag < 8))
AND obj = o. object_id
AND o.owner not in ('SYSTEM','SYS')
GROUP BY o.owner, object_name, object_type
ORDER BY buffers;

----修改对象定义
alter table t storage(buffer_pool recycle);

alter index test.BM_IDX_BT storage(buffer_pool RECYCLE);

有三点疑问:

a、如果keep池够大,是否可以将频繁使用的大表都放进去?有没有一个用于分辨的方法。
b、keep、default、recycle池的算法是否一样,比如如果recycle够大,是不是也可以当keep池用。
c、如果我把某个表使用keep池,但是我却不给keep池分配内存,结果会如何。

[ 本帖最后由 foxmile 于 2008-6-24 10:24 编辑 ]

TAG:

shiri512003发布于2008-06-24 10:38:45
首先要搞清楚为什么引入Multiple Buffer Pools
引用官方文档
[php]
http://download.oracle.com/docs/ ... 1/memory.htm#i30935
A single default buffer pool is generally adequate for most systems. However, users with detailed knowledge of an application's buffer pool might benefit from configuring multiple buffer pools.

With segments that have atypical access patterns, store blocks from those segments in two different buffer pools: the KEEP pool and the RECYCLE pool. A segment's access pattern may be atypical if it is constantly accessed (that is, hot) or infrequently accessed (for example, a large segment accessed by a batch job only once a day).

Multiple buffer pools let you address these differences. You can use a KEEP buffer pool to maintain frequently accessed segments in the buffer cache, and a RECYCLE buffer pool to prevent objects from consuming unnecessary space in the cache. When an object is associated with a cache, all blocks from that object are placed in that cache. Oracle maintains a DEFAULT buffer pool for objects that have not been assigned to a specific buffer pool. The default buffer pool is of size DB_CACHE_SIZE. Each buffer pool uses the same LRU replacement policy (for example, if the KEEP pool is not large enough to store all of the segments allocated to it, then the oldest blocks age out of the cache).

By allocating objects to appropriate buffer pools, you can:

Reduce or eliminate I/Os

Isolate or limit an object to a separate cache
[/php]
三种cache的说明,引用concept
[php]The KEEP buffer pool retains the schema object's data blocks in memory.

The RECYCLE buffer pool eliminates data blocks from memory as soon as they are no longer needed.

The DEFAULT buffer pool contains data blocks from schema objects that are not assigned to any buffer pool, as well as schema objects that are explicitly assigned to the DEFAULT pool.[/php]

搞清原理之后,再去具体问题具体分析。
cache不是万能的,要合理的使用
蚊子窝 foxmile 发布于2008-06-24 10:43:34
定义是死的,使用却是活的。
我明白每个池的作用,但是我的疑问,定义并不能解惑
shiri512003发布于2008-06-24 10:53:48
to:如果keep池够大,是否可以将频繁使用的大表都放进去?有没有一个用于分辨的方法。
频繁使用是指什么呢?
1、如果是频繁使用该表,但每次使用都是访问不同的数据,而且每次访问的数据量都很小,那么就cache的使用效率来讲,是不合适的,当然有keep的话随便吧
2、如果是频繁大量访问该表的数据,那么这时候cache的投入所产生的效益就是很高的,也可以一定程度上防止default cache抖动,所以oracle也是推荐这时候使用keep的
投入要计算效益,如果不计效益的话,那就没什么好说的了,只要别让投入的增加变成系统负担就可以了
shiri512003发布于2008-06-24 10:54:37
to:keep、default、recycle池的算法是否一样,比如如果recycle够大,是不是也可以当keep池用
定义清楚的话,这个没什么好说的
蚊子窝 foxmile 发布于2008-06-24 10:59:04

QUOTE:

原帖由 shiri512003 于 2008-6-24 10:54 发表
to:keep、default、recycle池的算法是否一样,比如如果recycle够大,是不是也可以当keep池用
定义清楚的话,这个没什么好说的
在生产上没有做过这种设置。测试一下。
我来说两句

(可选)

日历

« 2008-08-22  
     12
3456789
10111213141516
17181920212223
24252627282930
31      

数据统计

  • 访问量: 4135
  • 日志数: 139
  • 图片数: 1
  • 建立时间: 2007-12-10
  • 更新时间: 2008-08-01

RSS订阅

Open Toolbar