Professional Documents
Culture Documents
12c In-Memory Oracle
12c In-Memory Oracle
08 September 2016
Introduction
The In-Memory Column Store (IM column store) is the headline feature of the 12.1.0.2 patch set.
This features allows us to store columns, tables, partitions and materialized views in memory in a
columnar format, rather than the traditional row format.
Extremely well for analytic queries found in business intelligence products.
Up until now We have been forced to pick just one format and suffer the tradeoff of either
sub-optimal OLTP or
sub-optimal analytics performance [OLAP].
9 May 2016
Oracle Database In-Memory (Database In-Memory) provides the best of both worlds by allowing
data to be simultaneously
a. Populated in both an in-memory row format (the buffer cache) and
b. A new in-memory column format[In-memory Area]
The database maintains full transactional consistency between the row and the columnar
formats, just as it maintains consistency between tables and indexes.
The Oracle Optimizer is fully aware of the column format: It automatically routes analytic queries
to the column format and OLTP operations to the row format.
9 May 2016
The In-Memory column store is a new static pool of the SGA, sized using the
INMEMORY_SIZE initialization parameter [default 0].
Database In-Memory uses an In-Memory column store (IM column store), which is a new
component of the Oracle Database System Global Area (SGA), called the In-Memory
Area.
The IM column store does not replace the buffer cache, but acts as a supplement
We can choose to store specific groups of columns, whole tables, materialized views or
table partitions in the store.
Alternatively, we can enable IM column store at the tablespace level, so all tables and
materialized views in the tablespace are automatically enabled for the IM column store.
Of course, if our database is small enough, we can populate all of our tables into the IM
column store.
9 May 2016
9 May 2016
9 May 2016
There are several ways to disable the IM column store, depending on what We are trying to achieve.
Setting the INMEMORY_FORCE parameter to "OFF" means objects will not be maintained in the IM
column store.
Switching it back to "DEFAULT" returns to the default behaviour.
-- System level
ALTER SYSTEM SET INMEMORY_FORCE=OFF;
ALTER SYSTEM SET INMEMORY_FORCE=DEFAULT;
Setting the INMEMORY_QUERY parameter to "DISABLE" means the optimiser will not consider the
IM column store to optimise queries. Switching it back to "ENABLE" reverts it to the default
functionality.
-- System level
ALTER SYSTEM SET INMEMORY_QUERY=DISABLE;
ALTER SYSTEM SET INMEMORY_QUERY=ENABLE;
-- Session level
ALTER SESSION SET INMEMORY_QUERY=DISABLE;
ALTER SESSION SET INMEMORY_QUERY=ENABLE;
To disable the IM column store completely and release the memory, reset the INMEMORY_SIZE
parameter.
ALTER SYSTEM RESET INMEMORY_SIZE SCOPE=SPFILE;
SHUTDOWN IMMEDIATE;
STARTUP;
9 May 2016
The following statement sets the In-Memory attribute on the table SALES, in the SH sample schema, but it
excludes the column PROD_ID.
ALTER TABLE sales INMEMORY NO INMEMORY(prod_id);
To indicate an object is no longer a candidate, and to instantly remove it from the IM column store,
simply specify the NO INMEMORY clause.
ALTER TABLE sales MODIFY PARTITION SALES_Q1_1998 NO INMEMORY;
9 May 2016
The important thing to remember here is *we* will be responsible for deciding which objects will benefit the most from
inclusion in the IM column store.
If We choose badly, we will waste a lot of memory that could be used by the buffer cache.
9 May 2016
NUMBER
) INMEMORY;
CREATE TABLE noim_tab (
id
NUMBER
) NO INMEMORY;
Creating a table with the NO INMEMORY clause is the same as not specifying the clause at all.
SELECT table_name, inmemory, inmemory_priority, inmemory_distribute,
inmemory_compression, inmemory_duplicate
FROM
TABLE_NAME
DISABLED
IM_TAB
ENABLED
NOIM_TAB
DISABLED
NONE
AUTO
NO DUPLICATE
9 May 2016
10
The ALTER TABLE command can change the IM status of the objects. The following example
flips the status.
ALTER TABLE IM_TAB NO INMEMORY;
ALTER TABLE NOIM_TAB INMEMORY MEMCOMPRESS FOR CAPACITY LOW;
ALTER TABLE DEFAULT_TAB INMEMORY PRIORITY HIGH;
SELECT table_name, inmemory, inmemory_priority, inmemory_distribute,
inmemory_compression, inmemory_duplicate
FROM
TABLE_NAME
-------------------DEFAULT_TAB
IM_TAB
NOIM_TAB
INMEMORY
-------ENABLED
DISABLED
ENABLED
AUTO
NO DUPLICATE
9 May 2016
11
v$im_column_level
WHERE
TABLE_NAME
SEGMENT_COLUMN_ID COLUMN_NAME
INMEMORY_COMPRESSION
1 ID
NO INMEMORY
IM_COL_TAB
2 COL1
IM_COL_TAB
3 COL2
IM_COL_TAB
4 COL3
IM_COL_TAB
5 COL4
NO INMEMORY
9 May 2016
12
TABLE_NAME
SEGMENT_COLUMN_ID COLUMN_NAME
INMEMORY_COMPRESSION
-------------------- ----------------- ------------------------------- --------------------IM_COL_TAB
1 ID
NO INMEMORY
IM_COL_TAB
2 COL1
NO INMEMORY
IM_COL_TAB
3 COL2
NO INMEMORY
IM_COL_TAB
4 COL3
FOR CAPACITY HIGH
IM_COL_TAB
5 COL4
NO INMEMORY
9 May 2016
13
Setting the default IM column store parameters for a tablespace means all tables and
materialized views in that tablespace will use those setting unless explicitly overridden.
SELECT tablespace_name,
def_inmemory,
def_inmemory_priority,
def_inmemory_distribute,
def_inmemory_compression,
def_inmemory_duplicate
FROM
dba_tablespaces
ORDER BY tablespace_name;
TABLESPACE_NAME
-----------------------------NEW_TS
SYSAUX
SYSTEM
TEMP
USERS
9 May 2016
14
The ALTER TABLESPACE command is used to change the IM column store parameters.
SELECT tablespace_name,
def_inmemory,
def_inmemory_priority,
def_inmemory_distribute,
def_inmemory_compression,
def_inmemory_duplicate
FROM
dba_tablespaces
ORDER BY tablespace_name;
TABLESPACE_NAME
-----------------------------NEW_TS
SYSAUX
SYSTEM
TEMP
USERS
9 May 2016
15
9 May 2016
16
PRIORITY
DESCRIPTION
CRITICAL
HIGH
MEDIUM
Object is populated after all CRITICAL and HIGH objects have been populated
LOW
Object is populated after all CRITICAL, HIGH, and MEDIUM objects have been populated
NONE
Objects only populated after they are scanned for the first time (Default)
9 May 2016
17
In Memory - Compression
LEVEL DESCRIPTION
NO MEMCOMPRESS
9 May 2016
18
Objects that are smaller than 64KB are not populated into memory, as they will waste a
considerable amount of
space inside the IM column store as memory is allocated in 1MB chunks.
The IM column store cannot be used on an Active Data Guard standby instance in the
current release.
However it can be used in a Logical Standby instance and in an instance maintained using
Oracle Golden Gate.
9 May 2016
19
Analytic queries typically reference only a small subset of the columns in a table
Database accesses only the columns needed by a query, and applies any WHERE clause filter
predicates to these columns directly without having to decompress them first. This greatly
reduces the amount of data that needs to be accessed and processed.
A further reduction in the amount of data accessed is possible due to the In-Memory Storage
Indexes that are automatically created and maintained on each of the columns in the IM column
store.
An In-Memory Storage Index keeps track of minimum and maximum values for each column in
an IMCU [in-memory column unit].
When a query specifies a WHERE clause predicate, the In-Memory Storage Index on the
referenced column is examined
to determine if any entries with the specified column value exist in each IMCU by comparing the
specified value(s)
to the minimum and maximum values maintained in the Storage Index.
If the column value is outside the minimum and maximum range for an IMCU, the scan of that
IMCU is avoided.
9 May 2016
20
For the IM column store to be truly effective, it has to be able to handle both bulk data loads and
online transaction processing.
9 May 2016
21
The more stale entries there are in an IMCU, the slower the scan of the IMCU will become.
Therefore Oracle Database will repopulate an IMCU when the number of stale entries in an
IMCU reaches a staleness threshold.
The staleness threshold is determined by taking into account the frequency of IMCU access
and the number of stale rows in the IMCU.
Repopulation is more frequent for IMCUs
that are accessed frequently
or have a higher percentage of stale rows.
9 May 2016
22
In addition to the standard repopulation algorithm, there is another algorithm that attempts to
clean all stale entries using a low priority background process, known as trickle repopulate
The IMCO (In-Memory Coordinator) background process carries out repopulation for any IMCU
that has some stale entries but does not currently meet the staleness threshold.
The IMCO wakes up every two minutes and checks to see if any population tasks need to be
completed.
The IMCO will also check to see if there are any IMCUs with stale entries [ higher that threshold ].
If it finds some it will trigger the worker processes to repopulate them.
The number of IMCUs repopulated via trickle repopulate in a given 2 minute window is limited
by the new initialization parameter
INMEMORY_TRICKLE_REPOPULATE_SERVERS_PERCENT.
This parameter controls the maximum percentage of time that worker processes can participate in
trickle repopulation activities.
The more worker processes that participate, the more IMCUs that can be trickle repopulated
However the more worker processes that participate the higher the CPU consumption.
You can disable trickle repopulation altogether by setting
INMEMORY_TRICKLE_REPOPULATE_SERVERS_PERCENT to 0.
9 May 2016
23