LoveUnix » ORACLE等数据库 » 几种不同表的cache方法
让LU留住您的每

一天 让LU博客留住您的每一天
2007-1-25 14:50 boypoo
几种不同表的cache方法

一、对于普通表的cache方法:
SQL> conn test/test 已连接。
SQL> alter table t1 storage (buffer_pool keep) cache;
表已更改。
查询普通表是否已经被cache:
  [table=80][tr][td]SQL> select table_name,cache,buffer_pool from user_TABLES;
TABLE_NAME                     CACHE      BUFFER_
------------------------------ ---------- -------
T1                                 Y      KEEP
[/td][/tr][/table]
二、对于普通LOB类型的segment的cache方法
[table=80][tr][td] SQL> desc t2
名称 是否为空? 类型
---------------------------------------- -------- ----------------------------
ID NUMBER
C2 CLOB
SQL> alter table t2 modify lob(c2) (storage (buffer_pool keep) cache);
表已更改。
[/td][/tr][/table]
三、对基于CLOB类型的对象的cache方法
[table=80][tr][td]SQL> desc lob1
名称 是否为空? 类型
----------------------------------------- -------- --------------- ID NUMBER
C1 XMLTYPE
SQL> alter table lob1 modify lob(c1.xmldata) (storage (buffer_pool keep) cache);
表已更改。
[/td][/tr][/table]
---to be continued---

2007-1-25 14:52 boypoo
那么,怎么测试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>


---end---

页: [1]
查看完整版本: 几种不同表的cache方法


Powered by Discuz! Archiver 5.5.0  © 2001-2006 Comsenz Inc.