Orcle 12c new features --- IM virtual column

1 Description

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.

In-Memory Virtual columns can virtual list some or all of the user-defined value of its concrete realization (pre-calculated), and inserted into the column of the In-Memory storage and stored with all non-virtual columns in the table.

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.

(For example, in advance of the value of a column of complex calculations, and the resulting value as a virtual column, the next direct use virtual column without the need to recalculate) by pre-computing can greatly improve query performance.

To insert columns into the IM IM virtual storage column, the parameters to be set 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 virtual column can not be inserted into the IM inline store.

Experiment 2 - Enable IM virtual column

2.1 To enable IM first columnar storage

INMEMORY_SIZE value is not 0, the minimum of 100M.

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

2.2 Setting parameters INMEMORY_VIRTUAL_COLUMNS

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

- restart to take effect

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

Table 2.3 will include the virtual column enable IM columnar storage

2.3.1 The existing table to add a virtual column columnar storage and enable IM

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

SQL> ALTER TABLE bonus INMEMORY;
Table altered.

- BONUS View table structure, more than one WEEKLY_SAL

SQL> desc bonus

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

2.3.2 new table (with a virtual column), and displays the specified column is inserted into the IM virtual storage column

  • New Table
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;
  • The column is inserted into the IM hrly_rate virtual storage in a column
ALTER TABLE LEI.emp INMEMORY(hrly_rate);

More detailed information refer to the official document:
http://docs.oracle.com/database/122/INMEM/populating-objects-in-memory.htm#INMEM-GUID-C0BC34D3-2BD8-41A5-B2F0-9AB109C1B617

Guess you like

Origin blog.csdn.net/qianglei6077/article/details/92794847