Chinaunix首页 | 论坛 | 博客
  • 博客访问: 371744
  • 博文数量: 48
  • 博客积分: 2562
  • 博客等级: 少校
  • 技术积分: 402
  • 用 户 组: 普通用户
  • 注册时间: 2005-11-03 09:10
个人简介

时不我待。

文章分类

全部博文(48)

文章存档

2020年(3)

2013年(1)

2012年(5)

2011年(9)

2010年(4)

2009年(9)

2008年(15)

2005年(2)

分类: Oracle

2009-08-31 14:51:05

在一个中项目用到cache 表,转载记录一下。


一、对于普通表的cache方法:
SQL> conn test/test 已连接。
SQL> alter table t1 storage (buffer_pool keep) cache;
表已更改。
查询普通表是否已经被cache:
  
SQL> select table_name,cache,buffer_pool from user_TABLES;
TABLE_NAME                     CACHE      BUFFER_
------------------------------ ---------- -------
T1                                 Y      KEEP


二、对于普通LOB类型的segment的cache方法
SQL> desc t2
名称 是否为空? 类型
---------------------------------------- -------- ----------------------------
ID NUMBER
C2 CLOB
SQL> alter table t2 modify lob(c2) (storage (buffer_pool keep) cache);
表已更改。

三、对基于CLOB类型的对象的cache方法
 
SQL> desc lob1
名称 是否为空? 类型
----------------------------------------- -------- --------------- ID NUMBER
C1 XMLTYPE
SQL> alter table lob1 modify lob(c1.xmldata) (storage (buffer_pool keep) cache);
表已更改。

那么,怎么测试lob segment是否被cache了呢?

来看看oracle给我的回复:

Hi Frank,

To verify which buffer pool is used by a lob segment query dba_segments,

See below test case

SQL> create table test(name varchar2(10), address clob);

Table created.

SQL> select table_name,cache,buffer_pool from user_TABLES;

TABLE_NAME CACHE BUFFER_
------------------------------ ----- -------
TEST N DEFAULT


SQL> alter table test modify lob(address) (storage (buffer_pool keep) nocache);

Table altered.

SQL> select table_name,cache,buffer_pool from user_TABLES;

TABLE_NAME CACHE BUFFER_
------------------------------ ----- -------
TEST N DEFAULT

SQL> select segment_name,segment_type,buffer_pool from user_segments;

SEGMENT_NAME
--------------------------------------------------------------------------------
SEGMENT_TYPE BUFFER_
------------------ -------
TEST
TABLE DEFAULT

SYS_IL0000123006C00002$$
LOBINDEX KEEP

SYS_LOB0000123006C00002$$
LOBSEGMENT KEEP


SQL> select column_name,segment_name from user_lobs;

COLUMN_NAME
--------------------------------------------------------------------------------
SEGMENT_NAME
------------------------------
ADDRESS
SYS_LOB0000123006C00002$$


SQL>

Thus you can see the lob segment SYS_LOB0000123006C00002$$ is mapped to clob column ad
dress and is using
keep buffer pool as expected.

User_objects will display results for object as a whole not for individual columns.

See below, we need to alter the complete table to use keep buffer_pool and user_tables will then
display results as expected.

SQL> alter table test storage (buffer_pool keep);

Table altered.

SQL> select table_name,cache,buffer_pool from user_TABLES;

TABLE_NAME CACHE BUFFER_
------------------------------ ----- -------
TEST N KEEP

SQL>
阅读(3423) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~