Oracle中Cache表的使用

时间:2021-05-02

一、对于普通表的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>

声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。

相关文章