欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

oracle中如何将表缓存到内存中

程序员文章站 2022-07-15 08:58:17
...
转载http://www.2cto.com/database/201307/229265.html
oracle中如何将表缓存到内存中

由于在一些静态资料表在数据库中被频繁的访问,所以可以考虑将这些数据量不大的表缓存到内存当中。

共有2种方法:

例:将CUSTOMER_TYPE表缓存到内存中
1)alter table CUSTOMER_TYPE cache;
2)alter table CUSTOMER_TYPE storage(buffer_pool keep); 
--取消缓存
1)alter table CUSTOMER_TYPE nocache;
2)alter table CUSTOMER_TYPE storage(buffer_pool default);
 
 select table_name,OWNER,cache,buffer_pool from dba_tables where table_name='CUSTOMER_TYPE';  --查看是否缓存
 select * from dba_segments where segment_name='CUSTOMER_TYPE' ;          --查看表大小


两者区别:

  1) cache是将表缓存到share pool 中,该操作直接将表缓存的热端,受LRU算法控制。

  2)将表缓存到一个固定的内存空间中,默认情况下buffer_pool空间为0,。需手动设置空间大小。

alter system set db_keep_cache_size=50M scope=both sid=‘*';

相关标签: cache oracle