文档详情

06 数据库表常驻内存方案.docx

发布:2017-12-13约9.64千字共14页下载文档
文本预览下载声明
oracle将公共表数据常驻oracle数据缓存中1、首先评估公共数据表数据大小,决定db_keep_cache_size大小alter system set db_keep_cache_size=100M scope=both;2、修改表格属性,让它可以常驻内存alter table tbtest storage(buffer_pool keep);select table_name,tablespace_name,cache from user_tables;(此时cache为YES)3、如果需要取消该属性,执行下面语句alter table tbtest storage(buffer_pool default) ;[@more@]SQL select component,current_size from v$sga_dynamic_components where component=KEEP buffer cache;COMPONENT CURRENT_SIZE---------------------------------------------------------------- ------------KEEP buffer cache这里keep pool 10M查看keep pool剩余大小SQL select p.name,a.cnum_repl total buffers,a.anum_repl free buffers from x$kcbwds a, v$buffer_pool pwhere a.set_id=p.LO_SETID and p.name=KEEP;NAME total buffers free buffers-------------------- ------------- ------------KEEP 1497 1497 可以看到没有使用过keep 池select component, current_size, min_size, max_size from v$sga_dynamic_components where component in (DEFAULT buffer cache,KEEP buffer cache,RECYCLE buffer cache);--查看放入Keep的对象select segment_name from dba_segments where BUFFER_POOL = KEEP;SEGMENT_NAME----------------------------------------T1--查看表的大小select bytes/1024/1024||M from dba_segments where segment_name=T1;--查看db_keep_cache_size实际占用空间SELECT SUBSTR (SUM (b.NUMBER_OF_BLOCKS) * 8192 / 1024 / 1024, 1, 5) || MTotal_SizeFROM ( SELECT o.OBJECT_NAME, COUNT (*)NUMBER_OF_BLOCKSFROM DBA_OBJECTS o, V$BH bh,dba_segments ddWHERE o.DATA_OBJECT_ID= bh.OBJDAND o.OWNER = dd.ownerAND dd.segment_name= o.OBJECT_NAMEAND dd.buffer_pool != DEFAULTGROUP BY o.OBJECT_NAMEORDER BY COUNT (*)) b;注意事项1.db_keep_cache_size的大小一定要比cache的表的容量大sqlserver:Declare @db_id int, @tbl_id intUse DATABASE_NAMESet @db_id = DB_ID(DATABASE_NAME)Set @tbl_id = Object_ID(Department)DBCC pintable (@db_id, @tbl_id)可将表Department设置为驻留内存。Declare @db_id int, @tbl_id intUse DATABASE_NAMESet @db_id = DB_ID(DATABASE_NAME)Set @tbl_id = Object_ID(Department)DBCC UNpintable (@db_id, @tbl_id)可将表Department取消设置为驻留内存。可以使用如下的SQL指令来检测执行情况:Select ObjectProperty(Object
显示全部
相似文档