在一个中项目用到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>
阅读(3516) | 评论(0) | 转发(0) |