APPLIES TO:
Oracle Database Exadata Express Cloud Service - Version N/A and later
Oracle Database Cloud Exadata Service - Version N/A and later
Oracle Database Cloud Service - Version N/A and later
Oracle Database - Enterprise Edition - Version 12.1.0.2 and later
Oracle Database Cloud Schema Service - Version N/A and later
Information in this document applies to any platform.
NOTE:
In the images and/or the document content below, the user information and data used represents fictitious data. Any similarity to actual persons, living or dead, is purely coincidental and not intended in any manner.
Steps to verify/enable In-Memory database feature.
Check database version is 12.1.0.2
SQL> Select * from v$version;
BANNER CON_ID
-------------------------------------------------------------------------------- ----------
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production 0
PL/SQL Release 12.1.0.2.0 - Production 0
CORE 12.1.0.2.0 Production 0
TNS for Linux: Version 12.1.0.2.0 - Production 0
NLSRTL Version 12.1.0.2.0 - Production 0
Setting of inmemory_size should be > 0
Before setting inmemory_size parameter
SQL> show parameter inmemory
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
inmemory_clause_default string
inmemory_force string DEFAULT
inmemory_max_populate_servers integer 0
inmemory_query string ENABLE
inmemory_size big integer 0
inmemory_trickle_repopulate_servers_ integer 1
percent
optimizer_inmemory_aware boolean TRUE
SQL> select name, value from v$sga;
NAME VALUE
-------------------- ----------
Fixed Size 2927336
Variable Size 201327896
Database Buffers 402653184
Redo Buffers 5459968
Configure database parameter
SQL> ALTER SYSTEM SET inmemory_size = 200m scope=spfile;
System altered.
After setting inmemory_size parameter(database restart require to take place of parameter)
SQL> show parameter inmemory
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
inmemory_clause_default string
inmemory_force string DEFAULT
inmemory_max_populate_servers integer 2
inmemory_query string ENABLE
inmemory_size big integer 200M
inmemory_trickle_repopulate_servers_ integer 1
percent
optimizer_inmemory_aware boolean TRUE
SQL> select name, value from v$sga;
NAME VALUE
-------------------- ----------
Fixed Size 2927336
Variable Size 264242456
Database Buffers 130023424
Redo Buffers 5459968
In-Memory Area 209715200
5 rows selected.
To test this using sh schema
SQL> conn sh/
Connected.
Before placing table to inmemory
SQL> SELECT table_name,
inmemory,
inmemory_priority,
inmemory_distribute,
inmemory_compression,
inmemory_duplicate
FROM user_tables
WHERE table_name='
TABLE_NAME INMEMORY INMEMORY INMEMORY_DISTRI INMEMORY_COMPRESS INMEMORY_DUPL
------------------------------ -------- -------- --------------- ----------------- -------------
1 row selected.
SQL> select pool, alloc_bytes, used_bytes, populate_status from v$inmemory_area;
POOL ALLOC_BYTES USED_BYTES POPULATE_STATUS
-------------------------- ----------- ---------- --------------------------
1MB POOL 0 0 OUT OF MEMORY
64KB POOL 0 0 OUT OF MEMORY
SQL> select owner, segment_name, populate_status from v$im_segments;
no rows selected
Command to place table into memory
SQL> alter table
Table altered.
After placing table to inmemory
SQL> SELECT cust_valid, Count(*)
FROM
GROUP BY cust_valid; 2 3
C COUNT(*)
- ----------
I 44879
A 10621
2 rows selected.
SQL> SELECT table_name,
inmemory,
inmemory_priority,
inmemory_distribute,
inmemory_compression,
inmemory_duplicate
FROM user_tables
WHERE table_name='
TABLE_NAME INMEMORY INMEMORY INMEMORY_DISTRI INMEMORY_COMPRESS INMEMORY_DUPL
------------------------------ -------- -------- --------------- ----------------- -------------
1 row selected.
SQL> select owner, segment_name, populate_status from v$im_segments;
OWNER SEGMENT_NAME POPULATE_
------------------------- ------------------------- ---------
SH
1 row selected.
SQL> select pool, alloc_bytes, used_bytes, populate_status from v$inmemory_area;
POOL ALLOC_BYTES USED_BYTES POPULATE_STATUS
-------------------------- ----------- ---------- --------------------------
1MB POOL 166723584 4194304 DONE
64KB POOL 25165824 131072 DONE
2 rows selected.
Verify using execution plan
SQL> set autotrace traceonly;
SQL> SELECT cust_valid, Count(*)
FROM
GROUP BY cust_valid;
2 rows selected.
Execution Plan
----------------------------------------------------------
Plan hash value: 1577413243
-----------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-----------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 2 | 4 | 28 (11)| 00:00:01 |
| 1 | HASH GROUP BY | | 2 | 4 | 28 (11)| 00:00:01 |
| 2 | TABLE ACCESS INMEMORY FULL|
-----------------------------------------------------------------------------------------
Statistics
----------------------------------------------------------
249 recursive calls
0 db block gets
273 consistent gets
5 physical reads
0 redo size
676 bytes sent via SQL*Net to client
552 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
17 sorts (memory)
0 sorts (disk)
2 rows processed
Feature usage ststistics will be populated after 7 days of database creation else it will return 2 rows.
While the explain plan may show the 'INMEMORY FULL', the final execution may or may not have gone in-memory.
If the table was not populated into the column store (not enough space, first access, etc.), the traditional buffer cache access
would have been used. Other things like SQL Monitor or tracing may be needed to actually confirm its use.
select name, detected_usages
from dba_feature_usage_statistics u1
where version=(select max(version)
from dba_feature_usage_statistics u2
where u2.name=u1.name and u1.name like 'In-%')