85 DBMS_INMEMORY
The DBMS_INMEMORY
package provides an interface for In-Memory Column Store (IM column store) functionality.
This chapter contains the following topics:
85.1 DBMS_INMEMORY Overview
This package contains procedures for populating and repopulating the IM column store, and for dropping IM expressions from a specified table.
IM Population and Repopulation
In-Memory population (population) occurs when the database reads existing row-format data from disk, transforms it into columnar format, and then stores it in the IM column store. Only objects with the INMEMORY
attribute are eligible for population.
Population, which transforms existing data on disk into columnar format, is different from repopulation, which loads new data into the IM column store. Repopulation occurs automatically after their columnar data undergo significant DML activity.
When an object has the INMEMORY
attribute and a priority other than NONE
, the database gradually populates the object in the IM column store according to an internal priority queue. Objects with priority of NONE
are populated only when they undergo a full scan.
The DBMS_INMEMORY.POPULATE
procedure forces immediate population of an object. The DBMS_INMEMORY.POPULATE_WAIT
function forces population of objects that meet specified priority criteria, and also specifies a timeout interval within which populate must complete. The DBMS_INMEMORY.REPOPULATE
procedure forces immediate repopulation of an object.
See Also:
Oracle Database In-Memory Guide to learn more about IM population
IM Expressions
IM expressions populate frequently evaluated query expressions in the IM column store for subsequent reuse. An IM expression is materialized as a hidden virtual column, prefixed with the string SYS_IME
, and is accessed in the same way as a non-virtual column.
When you use DBMS_INMEMORY_ADMIN.IME_CAPTURE_EXPRESSIONS
, the database adds the 20 hottest expressions to their respective tables as SYS_IME
columns and applies the default INMEMORY
column compression clause. If any SYS_IME
columns that were added during a previous invocation are no longer in the latest expression list, then the database changes their attribute to NO INMEMORY
.
The maximum number of SYS_IME
columns for a table, regardless of whether the attribute is INMEMORY
or NO INMEMORY
, is 50. After the 50 expression limit is reached for a table, the database will not add new SYS_IME
columns. To make space for new expressions, you must manually drop SYS_IME
columns with the DBMS_INMEMORY.IME_DROP_EXPRESSIONS
or DBMS_INMEMORY_ADMIN.IME_DROP_ALL_EXPRESSIONS
procedures.
See Also:
Oracle Database In-Memory Guide to learn more about IM expressions
85.2 DBMS_INMEMORY Security Model
The DBMS_INMEMORY package subprograms execute with invoker’s rights.
The POPULATE
and REPOPULATE
procedures require the invoking user to have SELECT
privileges on the specified object. For IME_DROP_EXPRESSIONS
, the invoking user must have ALTER TABLE
privileges on the specified table.
85.3 Summary of DBMS_INMEMORY Subprograms
This table lists and briefly describes the DBMS_INMEMORY
package subprograms.
Table 85-1 DBMS_INMEMORY Package Subprograms
Subprogram | Description |
---|---|
Drops a specified set of |
|
Forces population of the specified table |
|
Initiates population of all |
|
Forces repopulation of the specified table |
|
Deallocates non-current IMCUs in the IM column store |
85.3.1 IME_DROP_EXPRESSIONS Procedure
This procedure drops a specified set of SYS_IME
virtual columns from a table.
Syntax
DBMS_INMEMORY.IME_DROP_EXPRESSIONS(
schema_name IN VARCHAR2,
table_name IN VARCHAR2,
column_name IN VARCHAR2 DEFAULT NULL);
Parameters
Table 85-2 IME_DROP_EXPRESSIONS Procedure Parameters
Parameter | Description |
---|---|
|
The name of the schema that contains the In-Memory table |
|
The name of the In-Memory table that contains the |
|
The name of the |
Usage Notes
Typical reasons for dropping SYS_IME
columns are space and performance. The maximum number of SYS_IME
columns for a table, regardless of whether the attribute is INMEMORY
or NO INMEMORY
, is 50. After the 50-expression limit is reached for a table, the database will not add new SYS_IME
columns. To make space for new expressions, you must manually drop SYS_IME
columns with the DBMS_INMEMORY.IME_DROP_EXPRESSIONS
or DBMS_INMEMORY_ADMIN.IME_DROP_ALL_EXPRESSIONS
procedures.
To drop a specified SYS_IME
column or all SYS_IME
columns in the requested table, use DBMS_INMEMORY.IME_DROP_EXPRESSIONS
. To populate these segments again, either invoke the DBMS_INMEMORY.POPULATE
procedure, or perform a full table scan.
85.3.2 POPULATE Procedure
This procedure forces population of the specified table, partition, or subpartition into the IM column store.
Syntax
DBMS_INMEMORY.POPULATE(
schema_name IN VARCHAR2,
table_name IN VARCHAR2,
subobject_name IN VARCHAR2 DEFAULT NULL);
Parameters
Table 85-3 POPULATE Procedure Parameters
Parameter | Description |
---|---|
|
Name of schema |
|
Name of table |
|
Partition or subpartition |
85.3.3 POPULATE_WAIT Function
This function initiates population of all INMEMORY
objects that have a priority greater than or equal to the specified priority, and returns a status value for the population. A user-specified interval specifies the maximum time that the function waits before returning the value to the caller.
Syntax
DBMS_INMEMORY.POPULATE_WAIT(
priority IN VARCHAR2 DEFAULT 'LOW',
percentage IN NUMBER DEFAULT 100,
timeout IN NUMBER DEFAULT 99999999,
force IN VARCHAR2 DEFAULT FALSE)
RETURN VARCHAR2;
Parameters
Table 85-4 POPULATE_WAIT Function Parameters
Parameter | Description |
---|---|
|
Specifies that the database populate all
|
|
Specifies the percentage of population required for the function to consider population to be complete. The default is For example, if |
|
Specifies the number of seconds that must pass before the function returns Assume that |
|
Specifies that the database should drop all Assume that the |
Return Values
The following table describes the possible return values for POPULATE_WAIT
. The function returns the values 0
, 1
, 2
, and 3
only if the condition is met before the end of the interval specified by timeout
. For example, if timeout
is 600
, then the function returns 1
only if an out-of-memory error occurs before 600 seconds pass. The function returns -1
only if the end of the timeout interval occurs before the database completes the requested operation.
Table 85-5 Return Values for POPULATE_WAIT
Constant | Value | Description |
---|---|---|
|
|
The function timed out while waiting for population to complete. Existing population jobs continue running in the background after |
|
|
All objects that met the |
|
|
The In-Memory pool had insufficient memory to populate the objects that met the |
|
|
No |
|
|
The In-Memory column store is not enabled. |
Usage Notes
Sample use cases for ensuring that objects are populated include:
-
When the database is closed, open the database with
STARTUP RESTRICT
so that only administrators can access the database, and then executePOPULATE_WAIT
with the desired timeout setting. IfPOPULATE_WAIT
returns-1
, indicating a timeout, then reexecutePOPULATE_WAIT
. When the function returns0
, disable the restricted session so that non-administrative users can query the database. -
Block database connections by using services or an application tier technique. When no analytic indexes exists, and when the application depends on the IM column store to provide reasonable performance, these techniques prevent runaway queries.
Example 85-1 Specifying a Timeout Interval for In-Memory Population
In this example, the database contains a number of In-Memory tables with a variety of priority settings. Your goal is to populate every In-Memory table to 100% completion in a restricted database session, and then disable the restricted session so that the application can be guaranteed of querying only the In-Memory representations.
Assume that the database is shut down. In SQL*Plus, you connect to an idle instance as SYSDBA
, and then execute the following command (sample output included):
SQL> STARTUP RESTRICT
ORACLE instance started.
Total System Global Area 1157624280 bytes
Fixed Size 8839640 bytes
Variable Size 754974720 bytes
Database Buffers 16777216 bytes
Redo Buffers 7933952 bytes
In-Memory Area 369098752 bytes
Database mounted.
Database opened.
The database is open, but is accessible only to administrative users. You execute the following statements in SQL*Plus (sample output shown in bold):
VARIABLE b_pop_status NUMBER
SELECT DBMS_INMEMORY_ADMIN.POPULATE_WAIT(
priority => 'NONE' ,
percentage => 100 ,
timeout => 300 )
INTO b_pop_status
FROM DUAL;
PRINT b_pop_status
-1
After 5 minutes, the function returns the number –1
. This code indicates that the function timed out while waiting for population to complete. 5 minutes is not long enough to populate all INMEMORY
tables. You re-execute the SELECT
statement, specifying a 30-minute timeout:
SELECT DBMS_INMEMORY_ADMIN.POPULATE_WAIT(
priority => 'NONE' ,
percentage => 100 ,
timeout => 1800 )
INTO b_pop_status
FROM DUAL;
PRINT b_pop_status
0
After 8 minutes, the function returns the number 0
. This code indicates that all tables are completely populated. You now disable the restricted session so that the application can start query In-Memory objects with full confidence that only In-Memory representations will be accessed:
ALTER SYSTEM DISABLE RESTRICTED SESSION;
85.3.4 REPOPULATE Procedure
This procedure forces repopulation of a table, partition, or subpartition that is currently populated in the IM column store.
Syntax
DBMS_INMEMORY.REPOPULATE(
schema_name IN VARCHAR2,
table_name IN VARCHAR2,
subobject_name IN VARCHAR2 DEFAULT NULL,
force IN BOOLEAN DEFAULT FALSE);
Parameters
Table 85-6 REPOPULATE Procedure Parameters
Parameter | Description |
---|---|
|
Name of the schema that owns the object. |
|
Name of the table requiring repopulation. |
|
Name of the partition or subpartition. If null, then repopulate the entire table. |
|
Whether to repopulate all IMCUs in the segment, just as in initial population. The following values are possible for the
For example, IMCU 1 contains rows 1 to 500,000, and IMCU 2 contains rows 500,001 to 1,000,000. A statement modifies row 600,000. When Consider further that the |
85.3.5 SEGMENT_DEALLOCATE_VERSIONS Procedure
This procedure deallocates non-current IMCUs in the IM column store.
Syntax
DBMS_INMEMORY.SEGMENT_DEALLOCATE_VERSIONS(
SCHEMA_NAME IN VARCHAR2,
TABLE_NAME IN VARCHAR2,
PARTITION_NAME IN VARCHAR2 DEFAULT NULL,
SPCPRESSURE IN BOOLEAN DEFAULT FALSE);
Parameters
Table 85-7 SEGMENT_DEALLOCATE_VERSIONS Procedure Parameters
Parameter | Description |
---|---|
|
Name of the schema that owns the object. |
|
Name of the table requiring repopulation. |
|
Name of the partition or subpartition. If null, then repopulate the entire table. |
|
Whether to force deallocation of non-current IMCUs ( |
Usage Notes
During repopulation, the IM column store maintains both the current IMCU and non-current IMCU. This mechanism, which is called double buffering, ensures that queries do not decrease performance because an IMCU is unavailable during repopulation. After repopulation completes, the IM column store retains the non-current IMCU for a short time (2 minutes by default) to optimize queries with older SCNs. Typically, the default behavior is sufficient. However, you can force deallocation of non-current IMCUs by using the SEGMENT_DEALLOCATE_VERSIONS
procedure.
Example
The following program forces deallocation of non-current IMCUs for the products
table:
BEGIN
DBMS_INMEMORY.SEGMENT_DEALLOCATE_VERSIONS(
schema_name => 'SH'
, table_name => 'PRODUCTS'
, spcpressure => TRUE );
END;
See Also:
Oracle Database In-Memory Guide to learn more about double buffering in the IM column store