在Oracle数据库12.2中,Heat Map特性增加了对Inmemory功能的支持。
在Oracle数据库18c中,引入了AIM(Automatic In Memory),允许对Inmemory列存储的内容进行自动管理。AIM会自动跟踪列的使用情况,通过热图数据,列统计信息和其他相关统计信息,决定哪些是最冷的对象。当Inmemory空间用完时,会自动的清除那些冷数据,让Inmemory真正的发挥作用。
注意:这个特性只能在Exadata、ODA和云上Exadata数据库服务环境上使用。
ExadataDatabase Cloud Service Enterprise Edition - Extreme Performance
Exadata Cloud Service
Oracle Database Appliance
如果在非Exadata、ODA环境启用自动Inmemroy,会出现下面的错误提示
SQL> alter system set inmemory_automatic_level=high scope=both sid='*'; alter system set inmemory_automatic_level=high scope=both sid='*' * ERROR at line 1: ORA-32017: failure in updating SPFILE ORA-12754: Feature 'Automatic In-Memory' is disabled due to missing capability 'Runtime Environment'. SQL>要启用Automatic In Memory功能,我们需要设置一个初始化参数INMEMORY_AUTOMATIC_LEVEL,在18.3中这个参数有三个值
LOW:当Inmemory内存存在压力时,数据库将从IM列存储中清除冷数据
MEDIUM:当Inmemory内存存在压力时,能保证任何热数据不被首先清除出去。
OFF:这是默认值。当设置此值时,将禁用自动内存功能。将返回到Oracle数据库18c之的行为。
在19c之前Inmemory是这样用的
为Inmemory设置一块区域
ALTER SYSTEM SET inmemory_size = 20G scope=spfile;
将数据放入inmemory
ALTER TABLE SH.customers INMEMORY;
可以根据需要将某些自动或者分区排除
ALTER TABLE SH.sales INMEMORY NO INMEMORY(prod_id);
ALTER TABLE SH.products INMEMORY PRIORITY LOW;
在19c中一键搞定
INMEMORY_AUTOMATIC_LEVEL增加了一个新的值HIGH,我们只需设置一个大小,设置一个级别HIGH,就全搞定了
为Inmemory设置一块区域ALTER SYSTEM SET inmemory_size = 20G scope=spfile;
设置自动Inmemroy的级别
ALTER SYSTEM SET INMEMORY_AUTOMATIC_LEVEL = HIGH scope=spfile;
19c Inmemory初始化参数链接
https://docs.oracle.com/en/database/oracle/oracle-database/19/inmem/init-parameters-for-im-column-store.html
https://docs.oracle.com/en/database/oracle/oracle-database/20/inmem/init-parameters-for-im-column-store.html
19.5中的inmemory参数
SQL> show parameter inmemory
NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ inmemory_adg_enabled boolean TRUE inmemory_automatic_level string OFF inmemory_clause_default string inmemory_expressions_usage string ENABLE inmemory_force string DEFAULT inmemory_max_populate_servers integer 0 inmemory_optimized_arithmetic string DISABLE inmemory_prefer_xmem_memcompress string inmemory_prefer_xmem_priority string inmemory_query string ENABLE inmemory_size big integer 0 inmemory_trickle_repopulate_servers_ integer 1 percent inmemory_virtual_columns string MANUAL inmemory_xmem_size big integer 0 optimizer_inmemory_aware boolean TRUE
有用的视图和查询语句
v$IM_SEGMENTS
v$IM_USER_SEGMENTSv$INMEMORY_AREA
col policy_name for a10
col object_owner for a15
col object_name for a25
col object_type for a10
set linesize 150
select policy_name, action_type, condition_type, condition_days from dba_ilmdatamovementpolicies;
select i.policy_name, i.object_owner, i.object_name, i.object_type, i.enabled, i.deleted, m.action_type, m.condition_type, m.condition_days, t.policy_type
from dba_ilmobjects i, dba_ilmdatamovementpolicies m, dba_ilmpolicies t
where i.policy_name = m.policy_name
and i.policy_name = t.policy_name;
col display_name format a30
SELECT display_name
FROM v$statname
WHERE display_name LIKE 'IM%';
SELECT display_name
FROM v$statname
WHERE display_name IN ('IM scan CUs columns accessed','IM scan segments minmax eligible','IM scan CUs pruned');
COL POOL FORMAT a9
COL POPULATE_STATUS FORMAT a15
SELECT POOL, TRUNC(ALLOC_BYTES/(1024*1024*1024),2) "ALLOC_GB",
TRUNC(USED_BYTES/(1024*1024*1024),2) "USED_GB",
POPULATE_STATUS
FROM V$INMEMORY_AREA;
Reference
https://blogs.oracle.com/in-memory/oracle-database-20c-aim-enhancements
https://www.oracle.com/a/tech/docs/twp-oracle-database-in-memory-19c.pdf
https://blogs.oracle.com/in-memory/automatic-in-memory
https://docs.oracle.com/en/database/oracle/oracle-database/19/inmem/release-changes.html
https://docs.oracle.com/en/database/oracle/oracle-database/18/refrn/INMEMORY_AUTOMATIC_LEVEL.htmlhttps://blogs.oracle.com/in-memory/oracle-database-in-memory-2
https://blogs.oracle.com/in-memory/oracle-database-18c-dbim
https://blogs.oracle.com/in-memory/new-database-in-memory-features-in-oracle-database-release-122
https://blogs.oracle.com/in-memory/getting-started-with-oracle-database-in-memory-part-i-installing-enabling
How to Enable Automatic In-Memory Levelling In 18c (Doc ID 2446648.1)
Note Automatic Data Optimization (ADO) Supports Database In-Memory Column Store in 12.2 (Doc ID 2211831.1)
Information Lifecycle Management (ILM), Heat Map, Automatic Data Optimization (ADO) (Doc ID 1612385.1)
How to Verify / Enable In-Memory Database Configuration? (Doc ID 1929758.1)How Does Read Consistency Work With 12c Database In-Memory Option? (Doc ID 1954808.1)