签到成功

知道了

CNDBA社区CNDBA社区

Orcle 12c 新特性---In-Memory Virtual Columns

2017-08-09 17:00 2694 0 原创 Oracle 12C
作者: Expect-乐

 说明

In-Memory virtual columns enable some or all of the user-defined virtual columns on a table to have their values materialized (precalculated) and populated into the In-Memory Column Store along with all of the non-virtual columns for that table.http://www.cndba.cn/Expect-le/article/2088

In-Memory虚拟列可以使表中的一些或所有用户定义的虚拟列实现其值的具体化(预先计算),并将其插入到In-Memory的列存储中,并与所有非虚拟列一起存储在该表中。

Materializing the values of user-defined virtual columns into the In-Memory Column Store can greatly improve query performance by enabling the virtual column values to be scanned and filtered using In-Memory techniques such as SIMD (single instruction, multiple data) vector processing, just like a non-virtual column.

http://www.cndba.cn/Expect-le/article/2088

通过预先计算(比如,提前对某列的值进行复杂的运算,将得到的值作为一个虚拟列,下次直接使用虚拟列即可,无需重新计算),可以大大提高查询的性能。

http://www.cndba.cn/Expect-le/article/2088
http://www.cndba.cn/Expect-le/article/2088

为了将IM虚拟列插入到IM列式存储中,要设置INMEMORY_VIRTUAL_COLUMNS参数:

MANUAL (default): If a table is enabled for the IM column store, then no IM virtual columns defined on this table are eligible for population, unless they are explicitly set as INMEMORY.  --需要显示指定虚拟列

ENABLE: If a table is enabled for the IM column store, then all IM virtual columns defined on this table are eligible for population, unless they are explicitly set as NO INMEMORY. --除非显示指定虚拟列不插入

DISABLE:无法将IM虚拟列插入到IM列式存储中。

实验-启用IM虚拟列

2.1   首先要启用IM列式存储

INMEMORY_SIZE值不为0,最小为100M

ALTER SYSTEM SET INMEMORY_SIZE = 100M SCOPE=SPFILE;
SQL> SHOW PARAMETER INMEMORY_SIZE
NAME	     TYPE	    VALUE
------------------------------------ ---------------------- ------------------------------
inmemory_size	     big integer	    100M

http://www.cndba.cn/Expect-le/article/2088

http://www.cndba.cn/Expect-le/article/2088

2.2   设置INMEMORY_VIRTUAL_COLUMNS参数

SQL> SHOW PARAMETER INMEMORY_VIRTUAL_COLUMNS
NAME	     TYPE	    VALUE
------------------------------------ ---------------------- ------------------------------
inmemory_virtual_columns	     string	    MANUAL

http://www.cndba.cn/Expect-le/article/2088

--重启生效http://www.cndba.cn/Expect-le/article/2088

SQL> ALTER SYSTEM SET INMEMORY_VIRTUAL_COLUMNS=ENABLE SCOPE=SPFILE;
System altered.

2.3   将包含虚拟列的表启用IM列式存储

2.3.1  将已有的表添加虚拟列并启用IM列式存储

SQL> alter table bonus add(weekly_sal as (ROUND(SAL*12/52,2)));
Table altered.

SQL> ALTER TABLE bonus INMEMORY;
Table altered.

--查看BONUS表结构,多了一列WEEKLY_SAL

SQL> desc bonus

 Name	   Null?    Type
 ----------------------------------------- -------- ----------------------------
 ENAME	    VARCHAR2(10)
 JOB	    VARCHAR2(9)
 SAL	        NUMBER
 COMM	    NUMBER
 WEEKLY_SAL     NUMBER

2.3.2  新建表(包含虚拟列),并显示指定虚拟列插入到IM列式存储

--新建表

CREATE TABLE  emp (
      empno      NUMBER(5) PRIMARY KEY,
      ename      VARCHAR2(15) NOT NULL,
      job        VARCHAR2(10),
      sal        NUMBER(7,2),
      hrly_rate NUMBER(7,2) GENERATED ALWAYS AS (sal/2080), --虚拟列将sal列除以2080
      deptno     NUMBER(3) NOT NULL)
   INMEMORY;

--hrly_rate虚拟列插入到IM列式存储中

http://www.cndba.cn/Expect-le/article/2088

ALTER TABLE LEI.emp INMEMORY(hrly_rate);

http://www.cndba.cn/Expect-le/article/2088

更为详细信息参考官方文档:

http://docs.oracle.com/database/122/INMEM/populating-objects-in-memory.htm#INMEM-GUID-C0BC34D3-2BD8-41A5-B2F0-9AB109C1B617

版权声明:本文为博主原创文章,未经博主允许不得转载。

In-Memory Virtual Columns

用户评论
* 以下用户言论只代表其个人观点,不代表CNDBA社区的观点或立场
Expect-乐

Expect-乐

关注

Without the continuous bitter cold, there can be no fragrant plum blossom

  • 336
    原创
  • 6
    翻译
  • 100
    转载
  • 41
    评论
  • 访问:1569024次
  • 积分:1957
  • 等级:核心会员
  • 排名:第4名
精华文章
    最新问题
    查看更多+
    热门文章
      热门用户
      推荐用户
        Copyright © 2016 All Rights Reserved. Powered by CNDBA · 皖ICP备2022006297号-1·

        QQ交流群

        注册联系QQ