一、为数据库启用IM column store,需要完成以下步骤:
1、数据库版本需12.1.0.2以上;
2、设置INMEMORY_SIZE初始化参数为非0值(最小要求100M);
3、重启数据库;
二、检查数据库哪些对象使用了inmemory,使用如下语句:
SELECT OWNER, SEGMENT_NAME, INMEMORY_PRIORITY, INMEMORY_COMPRESSION FROM V$IM_SEGMENTS;
三、查看数据库版本:
SQL> select * from v$version;
BANNER CON_ID
------------------------------------------------------------ ----------
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 0
64bit Production
PL/SQL Release 12.1.0.2.0 - Production 0
CORE 12.1.0.2.0 Production 0
TNS for Linux: Version 12.1.0.2.0 - Production 0
NLSRTL Version 12.1.0.2.0 - Production 0
四、启用IN-MEMORY特性
SQL> show parameter inmemory
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
inmemory_clause_default string
inmemory_force string DEFAULT
inmemory_max_populate_servers integer 0
inmemory_query string ENABLE
inmemory_size big integer 0
inmemory_trickle_repopulate_servers_ integer 1
percent
optimizer_inmemory_aware boolean TRUE
SQL> alter system set inmemory_size=200M scope=spfile;
System altered.
SQL> shu immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 1027604480 bytes
Fixed Size 2932096 bytes
Variable Size 738198144 bytes
Database Buffers 71303168 bytes
Redo Buffers 5455872 bytes
In-Memory Area 209715200 bytes =========》多了In-Memory Area
Database mounted.
Database opened.
SQL> show parameter inmemory
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
inmemory_clause_default string
inmemory_force string DEFAULT
inmemory_max_populate_servers integer 1
inmemory_query string ENABLE
inmemory_size big integer 200M
inmemory_trickle_repopulate_servers_ integer 1
percent
optimizer_inmemory_aware boolean TRUE
五、创建测试表
SQL> create table test_inmem(
2 id number(5) primary key,
3 test_col varchar2(15));
Table created.
注:SYS,SYSTEM,SYSAUX用户下的对象无法使用IM column store特性。
SQL> select TABLE_NAME,INMEMORY_PRIORITY,INMEMORY_DISTRIBUTE,INMEMORY_COMPRESSION from user_tables;
TABLE_NAME INMEMORY INMEMORY_DISTRI INMEMORY_COMPRESS
------------------------------ -------- --------------- -----------------
TEST_INMEM
SQL> alter table test_inmem inmemory;
Table altered
SQL> select TABLE_NAME,INMEMORY_PRIORITY,INMEMORY_DISTRIBUTE,INMEMORY_COMPRESSION from user_tables;
TABLE_NAME INMEMORY INMEMORY_DISTRI INMEMORY_COMPRESS
------------------------------ -------- --------------- -----------------
TEST_INMEM NONE AUTO FOR QUERY LOW