将程序、数据缓存、数据常驻内存

一,将程序常驻内存,这里的程序包括存储过程,触发器,包,序列等

需先执行相关包
SQL>@/u01/app/oracle/product/10.2.0/db_1/rdbms/admin/dbmspool.sql
SQL>exec dbms_shared_pool.keep('HR.Procedure1');(将存储过程注入内存)
SQL>SELECT name,namespace,sharable_mem,executions,kept from v$db_object_cache where owner='HR';(此时kept为YES)
SQL>exec dbms_shared_pool.unkeep('HR.ADD_JOB_HISTORY');(取消程序注入内存)


二,将数据缓存存在内存中,缓存到内存是指将数据放到Database buffers的LRU队列的队头, 随着时间的推移也可能会被淘汰出Database buffers.
alter table employees cache;(适用于常用的小表)
select table_name,tablespace_name,cache from user_tables;(此时cache为YES)。
alter table employees nocache;(取消缓存)


三,将数据(table,index)常驻内存.

首先应查询出需要常驻内存的数据量有多大

使用Analyze命令收集索引信息

Analyze index hr.emp_index compute statistics;

使用Dbms_stats包的gather_table_stats存储过程收集用户表信息

EXECUTE dbms_stats.gather_table_stats('HR','CUSTOMER');

查询dba_segments视图获取统计信息

select d.owner,d.segment_name,d.segment_type,d.blocks
from dba_segments d
where d.owner like 'DU%'
and d.segment_name in ('DUREX','USER_INFO')

得到Block数 Block*BlockSize/1024得到占用的空间大小(单位MB)

如1024×8/1024=8MB

设置Buffer bool的大小

SQL> show parameter db_keep

NAME                                 TYPE        VALUE
------------------------------------ ----------- -------
db_keep_cache_size                   big integer 0
SQL> alter system set db_keep_cache_size = 24M;

系统已更改。


alter table employees storage (buffer_pool keep);

 

查询:
select table_name,tablespace_name,buffer_pool from user_tables where table_name='EMPLOYEES';

Buffer pool列显示为Keep
alter table employees storage (buffer_pool default);--取消常驻内存
select id,name,block_size,buffers from v$buffer_pool;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值