You are on page 1of 16

Oracle® In-Memory Cost Management -

Database 12c Database In-Memory Option


Best Practices Guide

[Note ID 1632072.1]
Table of Contents
Oracle Database 12c Database In-Memory Option Best
Practice .................................................................................... 3

Introduction ..................................................................................... 3

Tuning SGA, PGA and In-Memory Size ................................................... 3

Loading Data into Database In-Memory Columnar Format ...................... 3

Appendix A Oracle Database 12c Database In-Memory Scripts


................................................................................................. 5

in_mem_pin_tables.sql ................................................................... 5

in_mem_status.sql ........................................................................ 14

in_mem_status_all.sql................................................................... 15
Oracle Database 12c Database In-Memory
Option Best Practice
Introduction
Oracle In-Memory Cost Management is engineered to work with Oracle Database 12c Database
In-Memory Option. This chapter provides some database tuning best practice to fully utilize the
power of Database In-Memory Option.

Tuning SGA, PGA and In-Memory Size

The database SGA and PGA size must be tuned to make better use of your specific resource
allocations. The following is an example to increase SGA to 40GB, PGA to 8GB and In-Memory Size
to 24GB. This can be used as a starting point for a medium size volume in Edge Deployment.

Stop all application services, except the database.

Login to the database as sysdba and issue these commands (remember to replace the example
values with your desired amount):

$ sqlplus / as sysdba

SQL> alter system set sga_max_size=40G scope=spfile;

SQL> alter system set sga_target=40G scope=spfile;

SQL> alter system set inmemory_size=24G scope=spfile;

SQL> alter system set pga_aggregate_target=8G scope=spfile;

SQL> alter system set pga_aggregate_limit=8G scope=spfile;

Bounce the database and restart application services.

Loading Data into Database In-Memory Columnar Format

A script has been provided in Appendix A for loading data into Database In-Memory. Copy the script
and save it as in_mem_pin_tables.sql in the target database server.

$ sqlplus apps/apps

SQL> alter system set inmemory_max_populate_servers=<parallel_threads>;

SQL> @in_mem_pin_tables.sql

where <parallel_threads> is a small integer indicating the number of parallel workers you want to use
to perform the data loading, such as 4.

3
Even after the script exits, the database may continue to load data into memory in the background.
The following scripts in the same appendix may be used to inspect the overall and detailed loading
status.

SQL> @in_mem_status_all

SQL> @in_mem_status

Depending on the size of your data volume, it may take up to an hour to complete.

Typically this process needs to be performed again whenever the database is shutdown and
restarted because the database releases its memory back to the operating system for other
processes to use when it shuts down.

4
Appendix A
Oracle Database 12c Database In-Memory
Scripts
in_mem_pin_tables.sql
DECLARE
l_dummy NUMBER;
CURSOR cand_query_tables IS
SELECT owner,
table_name,
owner||'.'||table_name full_name
FROM all_tables
WHERE temporary = 'N' AND table_name IN (
'AP_INVOICE_DISTRIBUTIONS_ALL',
'AP_INVOICE_LINES_ALL',
'AP_INVOICES_ALL',
'BOM_COMPONENTS_B',
'BOM_DEPARTMENTS',
'BOM_OPERATION_RESOURCES',
'BOM_OPERATION_SEQUENCES',
'BOM_OPERATIONAL_ROUTINGS',
'BOM_RESOURCES',
'BOM_STRUCTURES_B',
'CST_ACTIVITIES',
'CST_COGS_EVENTS',
'CST_RESOURCE_OVERHEADS',
'CST_REVENUE_COGS_MATCH_LINES',
'CST_SC_LISTS',
'CST_SC_LOW_LEVEL_CODES',
'CST_SC_ROLLUP_HISTORY',
'HZ_CUST_ACCOUNTS',
'HZ_CUST_ACCT_SITES_ALL',
'HZ_CUST_SITE_USES_ALL',
'HZ_PARTIES',
'JTF_RS_SALESREPS',
'MRP_ASSIGNMENT_SETS',
'MRP_SOURCING_RULES',
'MRP_SR_ASSIGNMENTS',
'MRP_SR_RECEIPT_ORG',
'MRP_SR_SOURCE_ORG',
'MTL_CATEGORIES_B',
'MTL_CATEGORY_SET_VALID_CATS',
'MTL_CATEGORY_SETS_B',
'MTL_DEFAULT_CATEGORY_SETS',
'MTL_CATEGORY_SETS_TL',
'MTL_INTERCOMPANY_PARAMETERS',
'MTL_INTERORG_SHIP_METHODS',
'MTL_ITEM_CATEGORIES',
'MTL_MATERIAL_TRANSACTIONS',
'MTL_ONHAND_QUANTITIES_DETAIL',

5
'MTL_SECONDARY_INVENTORIES',
'MTL_SUPPLY',
'MTL_SYSTEM_ITEMS_B',
'MTL_SYSTEM_ITEMS_TL',
'MTL_TRANSACTION_ACCOUNTS',
'MTL_TRANSACTION_FLOW_HEADERS',
'MTL_TRANSACTION_FLOW_LINES',
'OE_ORDER_HEADERS_ALL',
'OE_ORDER_LINES_ALL',
'RA_CUST_TRX_LINE_GL_DIST_ALL',
'RA_CUST_TRX_TYPES_ALL',
'RA_CUSTOMER_TRX_ALL',
'RA_CUSTOMER_TRX_LINES_ALL',
'RA_TERRITORIES',
'WIP_ACCOUNTING_CLASSES',
'WIP_DISCRETE_JOBS',
'WIP_ENTITIES',
'WIP_REQUIREMENT_OPERATIONS',
'MTL_ITEM_REVISIONS_B',
'MTL_ITEM_REVISIONS_TL',
'MTL_RTG_ITEM_REVISIONS',
'OE_SYS_PARAMETERS_ALL',
'ORG_ACCESS',
'PA_PROJ_ELEMENTS',
'CST_LC_ADJ_TRANSACTIONS',
'CST_SC_BOM_EXPLOSION',
'GL_CODE_COMBINATIONS',
'GL_JE_HEADERS',
'GL_JE_LINES',
'HR_ALL_POSITIONS_F',
'PO_DISTRIBUTIONS_ALL',
'PO_HEADERS_ALL',
'PO_LINE_LOCATIONS_ALL',
'PO_LINES_ALL',
'PO_SYSTEM_PARAMETERS_ALL',
'PON_AUCTION_ITEM_PRICES_ALL',
'PON_BID_HEADERS',
'PON_BID_ITEM_PRICES',
'RCV_TRANSACTIONS',
'WIP_TRANSACTION_ACCOUNTS',
'WIP_TRANSACTIONS');
CURSOR cand_dml_tables IS
SELECT owner,
table_name,
owner||'.'||table_name full_name
FROM all_tables
WHERE temporary = 'N' AND table_name IN (
'CST_COST_TYPES',
'CST_ITEM_COST_DETAILS',
'CST_DEPARTMENT_OVERHEADS',
'CST_ITEM_COSTS',
'CST_RESOURCE_COSTS',
'CST_SC_BOM_STRUCTURES',
'CST_SC_SOURCING_RULES',
'CMI_MARGIN_SUMMARY_F',
'CMI_ROLLUP_ORG_PRECISION',
'CMI_SC_BOM_EXPLOSION',

6
'CMI_SC_LISTS',
'CMI_SC_LOW_LEVEL_CODES',
'CMI_SC_PRE_LOW_LEVEL_CODES',
'CMI_SC_ROLLUP_BOM_COMP',
'CMI_CSBE_DELETED',
'CMI_CSLLC_LOT_SIZE',
'CMI_USER_CHANGES',
'CMI_UPDATE_CHANGES',
'CMI_GMF_BILLEXPL_PROD',
'CMI_GMF_BILLEXPL_TEMP',
'CMI_GMF_BILLEXPL_TEMP3',
'CMI_GMF_CR_BOM_EXPL_WU_GT',
'CMI_GMF_CR_FM_FORM_EFF_GT',
'CMI_GMF_CR_ITEM_WORK_GT',
'CMI_GMF_CR_LEAF_ITEMS_GT',
'CMI_GMF_CR_MATL_DTL1_GT',
'CMI_GMF_CR_MATL_DTL2_GT',
'CMI_GMF_CR_MATL_DTL4_GT',
'CMI_GMF_CR_MATL_DTL5_GT',
'CMI_GMF_CR_SRCORG_GT',
'CMI_GMF_FORMULA_OVERRIDES',
'CMI_GMF_FORMULA_STRUCTURES',
'CMI_GMF_IBOM',
'CMI_GMF_INDIV_IBOM',
'CMI_GMF_MARGIN_BUILD',
'CMI_GMF_OPRNDTL_TEMP',
'CMI_GMF_PURGE',
'CMI_GMF_ROUTDTL_TEMP',
'CMI_GMF_ROUTING_OVERRIDES',
'CMI_GMF_WHERE_USED',
'CMI_WHERE_USED',
'CMI_WHERE_USED_DETAILS',
'CMI_CAT_H',
'CMI_CAT_H_ARCHIVE',
'CMI_CUSTOMER_D_TABLE',
'CMI_GPA_CALENDAR_TIME_D',
'CMI_OU_INFO',
'CMI_PLANNED_IFACE_ERRORS',
'CMI_PLANNED_INTERFACE',
'CMI_PLANNED_ORDERS',
'CMI_PRODUCT_D_TABLE',
'CMI_TERRITORY_H',
'CMI_TIME_D',
'CMI_TXN_FLOWS',
'CMI_TXN_FLOW_HEADERS',
'CMI_TXN_FLOW_HEADER_EXP',
'CM_CMPT_DTL_B',
'CM_SCST_LED',
'CM_BRDN_DTL',
'CMI_CP_ALLOC_POOL_HEADERS',
'CMI_CP_ALLOC_POOL_HOOK_TBL',
'CMI_CP_ALLOC_POOL_LINES',
'CMI_CP_ITEM_DRIVER_HOOK_TBL',
'CMI_CP_ITEM_VOL_HOOK_TBL',
'CMI_CP_OVHD_DRIVER_HOOK_TBL',
'CMI_CP_OVHD_VOL_HOOK_TBL',
'CMI_CP_PLAN_ACTUAL_COGM',

7
'CMI_CP_PLAN_ALLOC_LINES',
'CMI_CP_PLAN_COST_TYPES',
'CMI_CP_PLAN_CURR_CONV',
'CMI_CP_PLAN_CURR_CONV_ERRORS',
'CMI_CP_PLAN_ERRORS',
'CMI_CP_PLAN_FIXED_COST_DTL',
'CMI_CP_PLAN_FIXED_COSTS',
'CMI_CP_PLAN_HEADERS',
'CMI_CP_PLAN_ITEM_ALLOC_AMT',
'CMI_CP_PLAN_ITEM_DRIVER_VAL',
'CMI_CP_PLAN_ITEM_PERIOD_VOL',
'CMI_CP_PLAN_ITEM_WU',
'CMI_CP_PLAN_OVHD_ALLOC_AMT',
'CMI_CP_PLAN_OVHD_DRIVER_VAL',
'CMI_CP_PLAN_OVHD_PERIOD_VOL',
'CMI_CP_PLAN_OVHD_WU',
'CMI_CP_PLAN_RES_ALLOC_AMT',
'CMI_CP_PLAN_RES_DRIVER_VAL',
'CMI_CP_PLAN_RES_PERIOD_VOL',
'CMI_CP_PLAN_RES_WU',
'CMI_CP_PLAN_RULES',
'CMI_CP_PLAN_SCOPE_ITEMS',
'CMI_CP_PLAN_SCOPE_OVHD',
'CMI_CP_PLAN_SCOPE_RES',
'CMI_CP_PLAN_SUB_ELE_ERRORS',
'CMI_CP_PLAN_UOM_ERRORS',
'CMI_CP_PLAN_WHERE_USED',
'CMI_CP_PLANS_FIRMED',
'CMI_CP_RES_DRIVER_HOOK_TBL',
'CMI_CP_RES_VOL_HOOK_TBL',
'CMI_CP_RULES',
'CMI_CP_SALES_ORDERS',
'CMI_CP_SCOPE_ATTRIBUTES',
'CMI_CP_SCOPE_HOOK_TBL',
'CMI_CP_SCOPES',
'CMI_CP_SUPPLY_DEMAND_ERRORS',
'CMI_CP_SUPPLY_DEMAND_HDR',
'CMI_CP_SUPPLY_DEMAND_IFACE',
'CMI_CP_SUPPLY_DEMAND_LINES',
'CMI_GPA_BUILD_RCT_DETAILS',
'CMI_WHERE_USED_HEADERS',
'CMI_WHERE_USED_IMPLOSIONS',
'CMI_WHERE_USED_SC_RULES'
);
CURSOR affected_tables IS
SELECT owner,
table_name,
owner||'.'||table_name full_name
FROM all_tables
WHERE temporary = 'N' AND table_name IN
('AP_INVOICE_DISTRIBUTIONS_ALL',
'AP_INVOICE_LINES_ALL',
'AP_INVOICES_ALL',
'BOM_ALTERNATE_DESIGNATORS',
'BOM_ALTERNATE_DESIGNATORS_TL',
'BOM_COMPONENTS_B',
'BOM_DEPARTMENTS',

8
'BOM_OPERATION_RESOURCES',
'BOM_OPERATION_SEQUENCES',
'BOM_OPERATIONAL_ROUTINGS',
'BOM_PARAMETERS',
'BOM_RESOURCES',
'BOM_STRUCTURES_B',
'CST_ACTIVITIES',
'CST_COGS_EVENTS',
'CST_COST_TYPES',
'CST_DEPARTMENT_OVERHEADS',
'CST_ITEM_COST_DETAILS',
'CST_ITEM_COSTS',
'CST_RESOURCE_COSTS',
'CST_RESOURCE_OVERHEADS',
'CST_REVENUE_COGS_MATCH_LINES',
'CST_SC_BOM_STRUCTURES',
'CST_SC_LISTS',
'CST_SC_LOW_LEVEL_CODES',
'CST_SC_ROLLUP_HISTORY',
'CST_SC_SOURCING_RULES',
'GL_DAILY_CONVERSION_TYPES',
'GL_DAILY_RATES',
'GL_FIXED_CONV_RATES',
'GL_LEDGERS',
'GL_PERIODS',
'HR_ALL_ORGANIZATION_UNITS',
'HR_ALL_ORGANIZATION_UNITS_TL',
'HR_ORGANIZATION_INFORMATION',
'HZ_CUST_ACCOUNTS',
'HZ_CUST_ACCT_SITES_ALL',
'HZ_CUST_SITE_USES_ALL',
'HZ_PARTIES',
'JTF_RS_SALESREPS',
'MRP_ASSIGNMENT_SETS',
'MRP_SOURCING_RULES',
'MRP_SR_ASSIGNMENTS',
'MRP_SR_RECEIPT_ORG',
'MRP_SR_SOURCE_ORG',
'MTL_CATEGORIES_B',
'MTL_CATEGORY_SET_VALID_CATS',
'MTL_CATEGORY_SETS_B',
'MTL_DEFAULT_CATEGORY_SETS',
'MTL_INTERCOMPANY_PARAMETERS',
'MTL_INTERORG_SHIP_METHODS',
'MTL_ITEM_CATEGORIES',
'MTL_CATEGORY_SETS_TL',
'MTL_LOT_UOM_CLASS_CONVERSIONS',
'MTL_MATERIAL_TRANSACTIONS',
'MTL_ONHAND_QUANTITIES_DETAIL',
'MTL_PARAMETERS',
'MTL_SECONDARY_INVENTORIES',
'MTL_SUPPLY',
'MTL_SYSTEM_ITEMS_B',
'MTL_SYSTEM_ITEMS_TL',
'MTL_TRANSACTION_ACCOUNTS',
'MTL_TRANSACTION_FLOW_HEADERS',
'MTL_TRANSACTION_FLOW_LINES',

9
'MTL_UNITS_OF_MEASURE_TL',
'MTL_UOM_CLASS_CONVERSIONS',
'MTL_UOM_CONVERSIONS',
'OE_ORDER_HEADERS_ALL',
'OE_ORDER_LINES_ALL',
'PJM_PROJECT_PARAMETERS',
'RA_CUST_TRX_LINE_GL_DIST_ALL',
'RA_CUST_TRX_TYPES_ALL',
'RA_CUSTOMER_TRX_ALL',
'RA_CUSTOMER_TRX_LINES_ALL',
'RA_TERRITORIES',
'WIP_ACCOUNTING_CLASSES',
'WIP_DISCRETE_JOBS',
'WIP_ENTITIES',
'WIP_REQUIREMENT_OPERATIONS',
'WSM_PARAMETERS',
'HR_LOCATIONS_ALL',
'HR_LOCATIONS_ALL_TL',
'PER_ORGANIZATION_STRUCTURES',
'PER_ORG_STRUCTURE_VERSIONS',
'PER_ORG_STRUCTURE_ELEMENTS',
'MTL_ITEM_REVISIONS_B',
'MTL_ITEM_REVISIONS_TL',
'MTL_RTG_ITEM_REVISIONS',
'CST_QUANTITY_LAYERS',
'CST_LAYER_COST_DETAILS',
'OE_SYS_PARAMETERS_ALL',
'CMI_CAT_H',
'CMI_CAT_H_ARCHIVE',
'CMI_CIS_PURGE',
'CMI_CSBE_DELETED',
'CMI_CSLLC_LOT_SIZE',
'CMI_CUSTOMER_D_TABLE',
'CMI_GMF_BILLEXPL_PROD',
'CMI_GMF_BILLEXPL_TEMP',
'CMI_GMF_BILLEXPL_TEMP3',
'CMI_GMF_CR_BOM_EXPL_WU_GT',
'CMI_GMF_CR_FM_FORM_EFF_GT',
'CMI_GMF_CR_ITEM_WORK_GT',
'CMI_GMF_CR_LEAF_ITEMS_GT',
'CMI_GMF_CR_MATL_DTL1_GT',
'CMI_GMF_CR_MATL_DTL2_GT',
'CMI_GMF_CR_MATL_DTL4_GT',
'CMI_GMF_CR_MATL_DTL5_GT',
'CMI_GMF_CR_SRCORG_GT',
'CMI_GMF_FORMULA_OVERRIDES',
'CMI_GMF_FORMULA_STRUCTURES',
'CMI_GMF_IBOM',
'CMI_GMF_INDIV_IBOM',
'CMI_GMF_MARGIN_BUILD',
'CMI_GMF_OPRNDTL_TEMP',
'CMI_GMF_PURGE',
'CMI_GMF_ROUTDTL_TEMP',
'CMI_GMF_ROUTING_OVERRIDES',
'CMI_GMF_SIMULATIONS',
'CMI_GMF_SIM_HISTORY',
'CMI_GMF_UPDATE_CHANGES',

10
'CMI_GMF_USER_CHANGES',
'CMI_GMF_WHERE_USED',
'CMI_GPA_CALENDAR_TIME_D',
'CMI_GPA_RPD_TL',
'CMI_MARGIN_BUILD',
'CMI_MARGIN_SUMMARY_F',
'CMI_OU_INFO',
'CMI_PLANNED_IFACE_ERRORS',
'CMI_PLANNED_INTERFACE',
'CMI_PLANNED_ORDERS',
'CMI_PRODUCT_D_TABLE',
'CMI_ROLLUP_ORG_PRECISION',
'CMI_SC_BOM_EXPLOSION',
'CMI_SC_LISTS',
'CMI_SC_LOW_LEVEL_CODES',
'CMI_SC_PRE_LOW_LEVEL_CODES',
'CMI_SC_ROLLUP_BOM_COMP',
'CMI_SIMLOAD_PARTITIONS',
'CMI_SIMULATIONS',
'CMI_SIM_HISTORY',
'CMI_SV_LAYOUT_GROUP',
'CMI_SV_LAYOUT_GROUP_COLS_B',
'CMI_SV_LAYOUT_GROUP_COLS_TL',
'CMI_SV_LAYOUT_HEADER',
'CMI_TERRITORY_H',
'CMI_TIME_D',
'CMI_TXN_FLOWS',
'CMI_TXN_FLOW_HEADERS',
'CMI_TXN_FLOW_HEADER_EXP',
'CMI_UPDATE_CHANGES',
'CMI_USER_CHANGES',
'CMI_WHERE_USED',
'CMI_WHERE_USED_DETAILS',
'ORG_ACCESS',
'CM_CMPT_DTL_B',
'CM_SCST_LED',
'GL_ITEM_DTL',
'GL_ITEM_CST',
'GMF_XLA_EXTRACT_HEADERS',
'GMF_XLA_EXTRACT_LINES',
'CM_WHSE_SRC',
'CR_RSRC_DTL',
'CM_CMPT_MST_B',
'CM_BRDN_DTL',
'CMI_CP_ALLOC_POOL_HEADERS',
'CMI_CP_ALLOC_POOL_HOOK_TBL',
'CMI_CP_ALLOC_POOL_LINES',
'CMI_CP_ITEM_DRIVER_HOOK_TBL',
'CMI_CP_ITEM_VOL_HOOK_TBL',
'CMI_CP_OVHD_DRIVER_HOOK_TBL',
'CMI_CP_OVHD_VOL_HOOK_TBL',
'CMI_CP_PLAN_ACTUAL_COGM',
'CMI_CP_PLAN_ALLOC_LINES',
'CMI_CP_PLAN_COST_TYPES',
'CMI_CP_PLAN_CURR_CONV',
'CMI_CP_PLAN_CURR_CONV_ERRORS',
'CMI_CP_PLAN_ERRORS',

11
'CMI_CP_PLAN_FIXED_COST_DTL',
'CMI_CP_PLAN_FIXED_COSTS',
'CMI_CP_PLAN_HEADERS',
'CMI_CP_PLAN_ITEM_ALLOC_AMT',
'CMI_CP_PLAN_ITEM_DRIVER_VAL',
'CMI_CP_PLAN_ITEM_PERIOD_VOL',
'CMI_CP_PLAN_ITEM_WU',
'CMI_CP_PLAN_OVHD_ALLOC_AMT',
'CMI_CP_PLAN_OVHD_DRIVER_VAL',
'CMI_CP_PLAN_OVHD_PERIOD_VOL',
'CMI_CP_PLAN_OVHD_WU',
'CMI_CP_PLAN_RES_ALLOC_AMT',
'CMI_CP_PLAN_RES_DRIVER_VAL',
'CMI_CP_PLAN_RES_PERIOD_VOL',
'CMI_CP_PLAN_RES_WU',
'CMI_CP_PLAN_RULES',
'CMI_CP_PLAN_SCOPE_ITEMS',
'CMI_CP_PLAN_SCOPE_OVHD',
'CMI_CP_PLAN_SCOPE_RES',
'CMI_CP_PLAN_SUB_ELE_ERRORS',
'CMI_CP_PLAN_UOM_ERRORS',
'CMI_CP_PLAN_WHERE_USED',
'CMI_CP_PLANS_FIRMED',
'CMI_CP_RES_DRIVER_HOOK_TBL',
'CMI_CP_RES_VOL_HOOK_TBL',
'CMI_CP_RULES',
'CMI_CP_SALES_ORDERS',
'CMI_CP_SCOPE_ATTRIBUTES',
'CMI_CP_SCOPE_HOOK_TBL',
'CMI_CP_SCOPES',
'CMI_CP_SUPPLY_DEMAND_ERRORS',
'CMI_CP_SUPPLY_DEMAND_HDR',
'CMI_CP_SUPPLY_DEMAND_IFACE',
'CMI_CP_SUPPLY_DEMAND_LINES',
'CMI_GPA_BUILD_RCT_DETAILS',
'CMI_WHERE_USED_HEADERS',
'CMI_WHERE_USED_IMPLOSIONS',
'CMI_WHERE_USED_SC_RULES',
'CST_LC_ADJ_TRANSACTIONS',
'CST_SC_BOM_EXPLOSION',
'GL_CODE_COMBINATIONS',
'GL_JE_HEADERS',
'GL_JE_LINES',
'HR_ALL_POSITIONS_F',
'PO_DISTRIBUTIONS_ALL',
'PO_HEADERS_ALL',
'PO_LINE_LOCATIONS_ALL',
'PO_LINES_ALL',
'PO_SYSTEM_PARAMETERS_ALL',
'PON_AUCTION_ITEM_PRICES_ALL',
'PON_BID_HEADERS',
'PON_BID_ITEM_PRICES',
'RCV_TRANSACTIONS',
'WIP_TRANSACTION_ACCOUNTS',
'WIP_TRANSACTIONS');
CURSOR select_column(p_tab_name IN VARCHAR2, p_owner IN VARCHAR2) IS
SELECT atc.column_name

12
FROM all_tab_columns atc
WHERE atc.owner = p_owner
AND atc.table_name = p_tab_name
AND atc.data_type IN ('VARCHAR2','NUMBER')
AND NOT EXISTS (SELECT 'x'
FROM all_ind_columns aic
WHERE aic.table_owner = atc.owner
AND aic.table_name = atc.table_name
AND aic.column_name = atc.column_name
)
AND rownum = 1;
l_busy_inmem_load NUMBER;
l_num_tries NUMBER;
BEGIN
/* Pin Query only tables to in mem */
FOR rec IN cand_query_tables LOOP
EXECUTE IMMEDIATE 'ALTER TABLE '||rec.full_name||' INMEMORY
MEMCOMPRESS FOR QUERY DUPLICATE ALL';
END LOOP;
/* Pin DML tables to in mem */
FOR rec IN cand_dml_tables LOOP
EXECUTE IMMEDIATE 'ALTER TABLE '||rec.full_name||' INMEMORY
MEMCOMPRESS FOR DML DUPLICATE ALL';
END LOOP;

/* run the selects so that tables are cached in memory */


FOR rec IN affected_tables LOOP
FOR rec2 IN select_column(rec.table_name,rec.owner) LOOP
l_num_tries := 0;
WHILE (l_num_tries < 60) LOOP
SELECT count(*)
INTO l_busy_inmem_load
FROM gv$im_segments
WHERE populate_status = 'STARTED';
IF (l_busy_inmem_load <> 0) THEN
dbms_lock.sleep(1);
l_num_tries := l_num_tries + 1;
ELSE
EXIT;
END IF;
END LOOP;
EXECUTE IMMEDIATE 'SELECT /*+ FULL(e_tab) */
count('||rec2.column_name||') FROM '||rec.full_name||' e_tab ' INTO
l_dummy;
END LOOP;
END LOOP;
l_num_tries := 0;
WHILE (l_num_tries < 60) LOOP
SELECT count(*)
INTO l_busy_inmem_load
FROM gv$im_segments
WHERE populate_status = 'STARTED';
IF (l_busy_inmem_load <> 0) THEN
dbms_lock.sleep(1);
l_num_tries := l_num_tries + 1;
ELSE
EXIT;

13
END IF;
END LOOP;
END;
/

SET line 500


SET pages 9999
col inst_id format 99 heading "inst"
col segment_name format a30 heading "Table"
col populate_status format a15 heading "Status"
col inmem_size_GB format 999.9999 heading "size"
col raw_data_size_GB format 999.9999 heading "Raw"
col GB_not_populated format 999.9999 heading "GBLeft"
col comp_ratio format 99.99 heading "Comp"
SELECT inst_id,
segment_name,
populate_status,
sum(inmemory_size/1024/1024/1024) inmem_size_GB,
sum(bytes/1024/1024/1024) raw_data_size_GB,
sum(bytes_not_populated/1024/1024/1024) GB_not_populated,
round(sum(bytes-bytes_not_populated)/sum(inmemory_size),2)
comp_ratio
FROM gv$im_segments
GROUP BY
inst_id,
segment_name,
populate_status
ORDER BY
populate_status, segment_name, inst_id
/

in_mem_status.sql
column inst_id format 99
column segment_name format a30
column populate_status format a15
column inmem_size_GB format 99.99
column raw_data_size_GB format 99.99
column GB_not_populated format 99.99
column comp_ratio format 99.99
set linesize 140
set pagesize 500

select inst_id,
segment_name,
populate_status,
sum(inmemory_size/1024/1024/1024) inmem_size_GB,
sum(bytes/1024/1024/1024) raw_data_size_GB,
sum(bytes_not_populated/1024/1024/1024) GB_not_populated,
sum(bytes)/sum(inmemory_size) comp_ratio
from gv$im_segments

14
group by inst_id,
segment_name,
populate_status
order by segment_name,inst_id;

in_mem_status_all.sql
column inst_id format 99
column segment_name format a30
column populate_status format a15
column inmem_size_GB format 99.99
column raw_data_size_GB format 99.99
column GB_not_populated format 99.99
column comp_ratio format 99.99
set linesize 140
set pagesize 500

select
sum(inmemory_size/1024/1024/1024) inmem_size_GB,
sum(bytes/1024/1024/1024) raw_data_size_GB,
sum(bytes_not_populated/1024/1024/1024) GB_not_populated,
sum(bytes)/sum(inmemory_size) comp_ratio
from gv$im_segments
;

15
Copyright © 2016, Oracle and/or its affiliates. All rights reserved.

This document is provided for information purposes only, and the contents hereof are subject to change without notice. This
Oracle Corporation document is not warranted to be error-free, nor subject to any other warranties or conditions, whether expressed orally or implied in
World Headquarters law, including implied warranties and conditions of merchantability or fitness for a particular purpose. We specifically disclaim any
500 Oracle Parkway liability with respect to this document, and no contractual obligations are formed either directly or indirectly by this document. This
Redwood Shores, CA 94065 document may not be reproduced or transmitted in any form or by any means, electronic or mechanical, for any purpose, without
U.S.A. our prior written permission.

Worldwide Inquiries: Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective
Phone: +1.650.506.7000 owners.
Fax: +1.650.506.7200
Intel and Intel Xeon are trademarks or registered trademarks of Intel Corporation. All SPARC trademarks are used under license and are
oracle.com trademarks or registered trademarks of SPARC International, Inc. AMD, Opteron, the AMD logo, and the AMD Opteron logo are trademarks or
registered trademarks of Advanced Micro Devices. UNIX is a registered trademark of The Open Group. 0114

16