SlideShare a Scribd company logo
Do’s and Don’ts of
Oracle Database In-Memory
Jorge Barba
Infrastructure Principal at Accenture Enkitec Group
https://jorgebarbablog.wordpress.com
Email: jorge.barba@accenture.com
Mar 2016
Agenda
2
A. Overview
B. Configuration
C. Optimizer
D. Queries
E. Usage with Oracle Technologies
F. Do's and Don'ts
G. Conclusion
Overview
4
Database In-Memory
In-Memory Column Store is an optional,
static SGA pool that stores segments in
columnar format.
It is a supplement to the Buffer Cache.
The database keeps the columnar data
transactionally consistent with the Buffer
Cache.
5
Row Format vs. Column Format
Transactions run faster on row format
Example: Query or Insert a sales order
Fast processing a few rows, many columns.
Analytics run faster on column format
Example: Report on sales totals by region
Fast accessing few columns, many rows
6
Dual Format Database
Same table on both formats
Analytics use the new in-memory Column Format
OLTP uses the Row Format
7
Scanning Memory
Buffer Cache
Have to walk along that row until we find
col4.
IM Column Store
Go directly to the col4 structure and scan
all the entries.
8
Storage Index
Storage Indexes
Automatically created and maintained
for each column in the Column Store.
Allow data pruning based on filter
predicates in the SQL statement.
Keeps track of minimum and maximum
values for each column in an IMCU.
If the column value is outside the
minimum and maximum range for an
IMCU, the scan of that IMCU is
avoided.
9
In-Memory Join and Bloom Filter (BF)
•  A Bloom filter transforms a join into a filter that can be
applied as part of the scan of the larger table.
•  Very efficiently applied to column format data via SIMD
vector processing.
•  Appears in two places, at creation time and again
when it is applied.
SELECT count(*)
FROM lineorder lo, part p
WHERE lo.lo_partkey=p.p_partkey
AND lo.lo_shipmode='TRUCK'
AND lo.lo_ordtotalprice between
55000000 and 56000000
AND p.p_name='papaya burlywood’;
10
Vector Group By
•  New optimizer transformation introduced with Oracle 12.1.0.2.0.
•  Find the total sales of footwear products in outlet stores.
•  The combination of these two phases dramatically improves the efficiency of a
multiple table join with complex aggregations.
| 9 | KEY VECTOR (USE) | :KV0000
| 10 | KEY VECTOR (USE) | :KV0001
11
SIMD Single Instruction Multiple Data
SIMD
A set of column values are evaluated together in a
single CPU instruction.
Designed to maximize the number of column
entries loaded and evaluated in a single CPU
instruction.
8 entries are loaded into the register for evaluation.
Configuration
13
Configuring the In-Memory Column Store
Configuration
•  INMEMORY_SIZE=1520M
•  Minimum of 100M
•  Part of the SGA
•  Fixed size
SQL> select * from v$sga;
NAME VALUE
-------------------- ----------
Fixed Size 2932632
Variable Size 587202664
Database Buffers 2097152000
Redo Buffers 13844480
In-Memory Area 1593835520
alter system set inmemory_size=1520M scope=spfile;
shutdown immediate;
startup
14
Populating the In-Memory Column Store
ALTER TABLE lineorder INMEMORY;
ALTER TABLE lineorder NO INMEMORY;
CREATE TABLE customer …
PARTITION BY LIST
(PARTITION p1 …… INMEMORY,
PARTITION p2 …… NO INMEMORY);
Eligible segments are:
•  Tables
•  Partitions
•  Subpartitions
•  Materialized Views
Not supported:
•  IOTs, Hash clusters, Out of line
LOBs.
15
Composition of In-Memory Area and DML
SQL> select pool, alloc_bytes
2 from v$inmemory_area;
POOL ALLOC_BYTES
-------------- -----------
1MB POOL 1274019840
64KB POOL 301989888
16
Composition of In-Memory Area and DML
•  Bulk Data Loads
•  Typically conducted as a direct path load.
•  The size of the missing data will be visible in
the BYTES_NOT_POPULATED column (V
$IM_SEGMENTS).
•  Partition Exchange Loads
•  Partition big tables or fact tables.
•  Transaction Processing
•  Single row data change operations (DML)
execute via the Buffer Cache.
17
Repopulation

•  Oracle Database will repopulate an IMCU when the
number of entries reaches a threshold.
•  Repopulation is more frequent for IMCUs that are
accessed frequently or have higher percentage of stale
rows.
•  Also the IMCO background process may also
repopulate.
18
Overhead

•  Keeping the IM Column Store
transactionally consistent.
•  Rate of change, compression level,
location of the changed rows, type of
operations being performed.
Optimizer
20
Optimizer
1.  In 12c the optimizer is fully aware of the In-
Memory Column Store. This means that the
optimizer will cost the read from the In-
memory Column Store.
2.  Using the same statistics and also new In-
Memory statistics
21
Optimizer 10053 trace
SELECT /* opt_trace_test */ sum(lo_revenue)
FROM lineorder lo, customer c
WHERE lo.lo_custkey=c.c_custkey
AND c_region='AFRICA';
column sql_text format a30
select sql_id, child_number,
sql_text from v$sql
where sql_text like
'%opt_trace_test%';
SQL_ID
-------------
5b8n5m6gtx71r
22
Optimizer 10053 trace (cont)
alter session set max_dump_file_size = unlimited;
execute DBMS_SQLDIAG.DUMP_TRACE(-
p_sql_id='5b8n5m6gtx71r', -
p_child_number=0, -
p_component='Optimizer', -
p_file_id='TRACE_10053');
How to Obtain Tracing of Optimizer Computations (EVENT 10053) (Doc ID 225598.1)
col value format a90
SELECT value
FROM v$diag_info
WHERE name='Default Trace File';
VALUE
---------------------------------------------------------------------------------------
/u01/app/oracle/diag/rdbms/db_inst2/DBNAME/trace/DB_INST2_ora_130114_TRACE_10053.trc
23
Optimizer 10053 trace (cont)
***************************************
BASE STATISTICAL INFORMATION
***********************
Table Stats::
Table: CUSTOMER Alias: C
#Rows: 120000 SSZ: 0 LGR: 0 #Blks: 1882 AvgRowLen: 107.00 NEB: 0 ChainCnt:
0.00 SPC: 0 RFL: 0 RNF: 0 CBK: 0 CHR: 0 KQDFLG: 1
#IMCUs: 1 IMCRowCnt: 120000 IMCJournalRowCnt: 3000 #IMCBlocks: 0 IMCQuotient:
1.000000
Column (#1): C_CUSTKEY(NUMBER)
AvgLen: 5 NDV: 120000 Nulls: 0 Density: 0.000008 Min: 1.000000 Max: 120000.000000
***********************
Table Stats::
Table: LINEORDER Alias: LO
#Rows: 23996670 SSZ: 0 LGR: 0 #Blks: 335060 AvgRowLen: 96.00 NEB: 0 ChainCnt:
0.00 SPC: 0 RFL: 0 RNF: 0 CBK: 0 CHR: 0 KQDFLG: 1
#IMCUs: 23 IMCRowCnt: 23996670 IMCJournalRowCnt: 599917 #IMCBlocks: 0
IMCQuotient: 1.000000
Column (#3): LO_CUSTKEY(NUMBER)
AvgLen: 5 NDV: 80504 Nulls: 0 Density: 0.000012 Min: 1.000000 Max: 119999.000000
24
Disabling and Enabling In-Memory
To disable In-Memory scans set the parameter
INMEMORY_QUERY = DISABLE
Plans will get the cost based on disk statistics and scans will be from the IM Column Store.
Use hint INMEMORY to force In-Memory Scan even if INMEMORY_QUERY is disabled.
NO_INMEMORY disables In-Memory scan even if the table is in the In-Memory Column Store.
SELECT /*+ INMEMORY */ sum(lo_revenue)
FROM lineorder lo, customer c
WHERE lo.lo_custkey=c.c_custkey
AND c_region='AFRICA’;
SELECT /*+ NO_INMEMORY */ sum(lo_revenue)
FROM lineorder lo, customer c
WHERE lo.lo_custkey=c.c_custkey
AND c_region='AFRICA’;
25
Optimizer Summary
•  In 12.1.0.2 the Optimizer is In-Memory aware.
•  In-Memory statistics automatically generated at parse.
•  Cost model adjusted for costing In-Memory Scans
•  New INMEMORY and NO_INMEMORY hints
Queries
27
Queries
•  We have chosen some of the
queries that are candidates to
benefit from Database In-
Memory.
28
Function MAX(column)
select max(lo_ordtotalprice)
from lineorder;
MAX(LO_ORDTOTALPRICE)
---------------------
55903140
Elapsed time: 0.004
select /*+ NO_INMEMORY */
max(lo_ordtotalprice)
from lineorder;
MAX(LO_ORDTOTALPRICE)
---------------------
55903140
Elapsed time: 4.014
29
Function MAX(column)
B-tree index on lo_ordtotalprice
create index ordtotalprice_ix on
lineorder(lo_ordtotalprice);
select /*+ NO_INMEMORY */
max(lo_ordtotalprice)
from lineorder;
MAX(LO_ORDTOTALPRICE)
---------------------
55903140
Elapsed time: 0.001
30
Function MAX(column)
How about Result Cache?
SQL show parameter result_cache_max_size
big integer 22000K
select /*+ RESULT_CACHE */
max(lo_ordtotalprice)
from lineorder;
MAX(LO_ORDTOTALPRICE)
---------------------
55903140
Elapsed time: 0.001
31
How do we know it used the In-Memory Column Store?
select n.name, s.value
from v$mystat s, v$statname n
where s.statistic#=n.statistic#
and n.name like 'IM scan CUs columns accessed';
-----------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-----------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 3 | 2224 (12)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | 3 | | |
| 2 | TABLE ACCESS INMEMORY FULL| LINEORDER | 24M| 68M| 2224 (12)| 00:00:01 |
-----------------------------------------------------------------------------------------
NAME VALUE
---------------------------------------------------------------- ----------
IM scan CUs columns accessed 45
32
One equality predicate
SELECT lo_orderkey,
lo_custkey, lo_revenue
FROM lineorder
WHERE lo_orderkey = 4000000;
LO_ORDERKEY LO_CUSTKEY LO_REVENUE
----------- ----------- -----------
4000000 51832 6983797
4000000 51832 917952
4000000 51832 2501733
4000000 51832 7895007
Elapsed time: 0.002
SELECT /*+ NO_INMEMORY */
lo_orderkey, lo_custkey,
lo_revenue
FROM lineorder
WHERE lo_orderkey = 4000000;
LO_ORDERKEY LO_CUSTKEY LO_REVENUE
----------- ----------- -----------
4000000 51832 6983797
4000000 51832 917952
4000000 51832 2501733
4000000 51832 7895007
Elapsed time: 4.528
IM scan CUs columns accessed 3
IM scan segments minmax eligible 44
IM scan CUs pruned 43
33
One equality predicate
B-tree index on lo_orderkey
create index lo_orderkey_ix
on lineorder (lo_orderkey);
SELECT /*+ NO_INMEMORY */
lo_orderkey, lo_custkey,
lo_revenue
FROM lineorder
WHERE lo_orderkey = 4000000;
LO_ORDERKEY LO_CUSTKEY LO_REVENUE
----------- ----------- -----------
4000000 51832 6983797
4000000 51832 917952
4000000 51832 2501733
4000000 51832 7895007
Elapsed time: 0.001
34
Three equality predicate
SELECT lo_orderkey, lo_custkey, lo_revenue
FROM lineorder
WHERE lo_custkey = 13286
AND lo_shipmode = 'TRUCK’
AND lo_orderpriority = '3-MEDIUM’;
LO_ORDERKEY LO_CUSTKEY LO_REVENUE
----------- ----------- -----------
8268262 13286 6777268
8268262 13286 6207689
9048868 13286 6394887
17521920 13286 2905822
19397281 13286 3573400
Elapsed time: 0.002
SELECT /*+ NO_INMEMORY */ lo_orderkey,
lo_custkey, lo_revenue
FROM lineorder
WHERE lo_custkey = 13286
AND lo_shipmode = 'TRUCK’
AND lo_orderpriority = '3-MEDIUM’;
LO_ORDERKEY LO_CUSTKEY LO_REVENUE
----------- ----------- -----------
8268262 13286 6777268
8268262 13286 6207689
9048868 13286 6394887
17521920 13286 2905822
19397281 13286 3573400
Elapsed time: 4.868
IM scan CUs columns accessed 3
IM scan segments minmax eligible 44
IM scan CUs pruned 43
35
How about composite index?
create index cust_ship_pri_ix
on lineorder
(lo_custkey, lo_shipmode,
lo_orderpriority);
SELECT /*+ NO_INMEMORY */ lo_orderkey,
lo_custkey, lo_revenue
FROM lineorder
WHERE lo_custkey = 13286
AND lo_shipmode = 'TRUCK’
AND lo_orderpriority = '3-MEDIUM’;
Customer#000118324 JORDAN
Customer#000119371 ETHIOPIA
Customer#000119386 SAUDI ARABIA
Customer#000118412
VIETNAMLO_ORDERKEY LO_CUSTKEY LO_REVENUE
----------- ----------- -----------
8268262 13286 6777268
8268262 13286 6207689
9048868 13286 6394887
17521920 13286 2905822
19397281 13286 3573400
Elapsed time: 0.001
36
Greater Than () Instead of Equality (=)
SELECT MAX(lo_ordtotalprice)
FROM lineorder
WHERE lo_quantity  74;
Elapsed time: 0.002
SELECT MAX(lo_ordtotalprice)
FROM lineorder
WHERE lo_quantity  74;
Elapsed time: 4.82
IM scan CUs columns accessed 3
IM scan segments minmax eligible 44
IM scan CUs pruned 43
37
How about an index?
create index lo_quantity_ix on
lineorder(lo_quantity);
SELECT /*+ INDEX(a lo_quantity_ix) */
MAX(lo_ordtotalprice)
FROM lineorder a
WHERE lo_quantity  74;
Elapsed time: 0.001
38
Bloom Filter Example
SELECT c.c_name, c.c_nation
FROM customer c, part p,
lineorder lo
WHERE lo.lo_custkey = c.c_custkey
AND lo.lo_partkey = p.p_partkey
AND p.p_name = 'white salmon';
C_NAME C_NATION
------------------------- ---------------
Customer#000118324 JORDAN
Customer#000119371 ETHIOPIA
Customer#000119386 SAUDI ARABIA
Customer#000118412 VIETNAM
...
...
39
Vector Group By Example
SELECT /*+ VECTOR_TRANSFORM */
c.c_name, c.c_nation,
sum(lo_ordtotalprice)
FROM customer c, part p,
lineorder lo
WHERE lo.lo_custkey = c.c_custkey
AND lo.lo_partkey = p.p_partkey
AND p.p_name = 'white salmon'
group by c.c_name, c.c_nation;
...
...
C_NAME C_NATION SUM(LO_ORDTOTALPRICE)
------------------------- --------------- ---------------------
Customer#000118540 ROMANIA 12634439
Customer#000119051 ARGENTINA 28032775
Customer#000118129 JAPAN 22258279
Customer#000118198 UNITED STATES 17849279
Usage with Oracle Technologies
41
RAC
Each node in a RAC environment has its own IM
column store.
Objects populated into memory will be
distributed across all of the IM column stores in
the cluster.
ALTER TABLE lineorder INMEMORY
DISTRIBUTE BY PARTITION;
ALTER TABLE lineorder INMEMORY
DISTRIBUTE AUTO DUPLICATE ALL;
42
M6-32
M6-32
SMP removes the overhead of distributing
queries across a cluster and coordinating
transactions.
Algorithms NUMA optimized.
Memory interconnect far faster than any
network.
43
Exadata
Exadata
Complete fault-tolerant In-Memory
solution.
Exceed DRAM limits and transparently
scale across Memory, Flash and Disk.
Initial population of data into the In-
Memory column store from storage is very
fast.
The In-Memory Aggregation optimization,
can be offloaded to Exadata storage cells
44
Oracle Technologies
•  Data Guard
•  Golden Gate
•  Oracle Multitenant
•  Partitioning
•  Parallelism
•  Resource Manager
•  RMAN
•  ALTER TABLE EXCHANGE
45
Partition Exchange
1.  Create external table for flat files
2.  Use CTAS to create non part table and
gather table stats
3.  Set INMEMORY attribute ON
4.  Populate non part table in column store
5.  Alter table table_name exchange partition
part name with table non part table;
Do’s and Don’ts
47
The benefits of IM Column Store
Speed up Scans, Joins, Aggregates.
Scan of large tables and using predicates like =, , , IN
Querying a subset of columns in a table, for example, selecting 5 of 100 columns.
Accelerating joins by converting predicates on small dimension tables into filters on a large
fact table.
48
Do or Don’t?
Business applications
Ad-hoc analytic queries
Data warehouse workloads
49
Do or Don’t?
OLTP databases
short transactions
using index lookups
50
Do
Queries that scan a large number of rows and apply filters that use operators such as the
following: =, , , and IN.
Queries that select a small number of columns from a table or materialized view with a
large number of columns, such as a query that selects five columns from a table with 100
columns.
Queries that join a small table to a large table.
Queries that aggregate data.
51
Don’t
Queries with complex predicates.
Queries that select a large number of columns.
Queries that return a large number of rows.
Queries with multiple large table joins.
52
Don’t
In-memory speeds up analytic data access, not:
Network round trips, logon/logoff
Parsing, PL/SQL, complex functions
Data processing (as opposed to access)
Complex joins or aggregations where not much data is filtered before processing
Load and select once - Staging tables, ETL, temp tables
Is it for me?
Conclusion
54
KEEP
CALM
AND
ASK
ME
Tú Pregúntame …
Please visit my blog at:
https://jorgebarbablog.wordpress.com
Email: jorge.barba@accenture.com

More Related Content

What's hot (20)

PPT
DB2UDB_the_Basics Day 4
Pranav Prakash
 
PDF
InnoDB MVCC Architecture (by 권건우)
I Goo Lee.
 
PPTX
What's New In MySQL 5.6
Abdul Manaf
 
PDF
What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1
MariaDB plc
 
DOC
DB2 utilities
Udayakumar Suseendran
 
PDF
M|18 Understanding the Query Optimizer
MariaDB plc
 
PDF
12c SQL Plan Directives
Franck Pachot
 
PDF
Query Optimizer in MariaDB 10.4
Sergey Petrunya
 
PDF
ALTER TABLE Improvements in MariaDB Server
MariaDB plc
 
PDF
Btree. Explore the heart of PostgreSQL.
Anastasia Lubennikova
 
PDF
MariaDB ColumnStore
MariaDB plc
 
PDF
PostgreSQL performance improvements in 9.5 and 9.6
Tomas Vondra
 
PPTX
Column store indexes and batch processing mode (nx power lite)
Chris Adkin
 
PDF
Юра Гуляев. Oracle tables
Aleksandr Motsjonov
 
PPT
DB2UDB_the_Basics Day 6
Pranav Prakash
 
PPTX
An introduction to column store indexes and batch mode
Chris Adkin
 
PPT
DB2UDB_the_Basics Day 5
Pranav Prakash
 
PDF
CBO choice between Index and Full Scan: the good, the bad and the ugly param...
Franck Pachot
 
PDF
Using histograms to get better performance
Sergey Petrunya
 
PDF
Performance improvements in PostgreSQL 9.5 and beyond
Tomas Vondra
 
DB2UDB_the_Basics Day 4
Pranav Prakash
 
InnoDB MVCC Architecture (by 권건우)
I Goo Lee.
 
What's New In MySQL 5.6
Abdul Manaf
 
What's New in MariaDB Server 10.2 and MariaDB MaxScale 2.1
MariaDB plc
 
DB2 utilities
Udayakumar Suseendran
 
M|18 Understanding the Query Optimizer
MariaDB plc
 
12c SQL Plan Directives
Franck Pachot
 
Query Optimizer in MariaDB 10.4
Sergey Petrunya
 
ALTER TABLE Improvements in MariaDB Server
MariaDB plc
 
Btree. Explore the heart of PostgreSQL.
Anastasia Lubennikova
 
MariaDB ColumnStore
MariaDB plc
 
PostgreSQL performance improvements in 9.5 and 9.6
Tomas Vondra
 
Column store indexes and batch processing mode (nx power lite)
Chris Adkin
 
Юра Гуляев. Oracle tables
Aleksandr Motsjonov
 
DB2UDB_the_Basics Day 6
Pranav Prakash
 
An introduction to column store indexes and batch mode
Chris Adkin
 
DB2UDB_the_Basics Day 5
Pranav Prakash
 
CBO choice between Index and Full Scan: the good, the bad and the ugly param...
Franck Pachot
 
Using histograms to get better performance
Sergey Petrunya
 
Performance improvements in PostgreSQL 9.5 and beyond
Tomas Vondra
 

Viewers also liked (8)

PPT
Memory Management for High-Performance Applications
Emery Berger
 
PPTX
Operating system memory management
rprajat007
 
PDF
Accenture at Oracle OpenWorld 2015
Accenture Technology
 
PDF
Deep Dive: Memory Management in Apache Spark
Databricks
 
PPTX
Operating System-Memory Management
Akmal Cikmat
 
PDF
8 memory management strategies
Dr. Loganathan R
 
PPS
Operating Systems and Memory Management
guest1415ae65
 
PPTX
The New Energy Consumer: What Promises Do Blockchain Technologies Offer Energ...
accenture
 
Memory Management for High-Performance Applications
Emery Berger
 
Operating system memory management
rprajat007
 
Accenture at Oracle OpenWorld 2015
Accenture Technology
 
Deep Dive: Memory Management in Apache Spark
Databricks
 
Operating System-Memory Management
Akmal Cikmat
 
8 memory management strategies
Dr. Loganathan R
 
Operating Systems and Memory Management
guest1415ae65
 
The New Energy Consumer: What Promises Do Blockchain Technologies Offer Energ...
accenture
 
Ad

Similar to Oracle Database InMemory (20)

PDF
Sloupcové uložení dat a použití in-memory technologií u řešení Exadata
MarketingArrowECS_CZ
 
PPTX
Geek Sync I Need for Speed: In-Memory Databases in Oracle and SQL Server
IDERA Software
 
PDF
12c In Memory Management - Saurabh Gupta
pasalapudi123
 
PDF
Oracle in-Memory Column Store for BI
Franck Pachot
 
PDF
Oracle Database In-Memory and the Query Optimizer
Christian Antognini
 
PDF
Oracle Database In-Memory Option for ILOUG
Zohar Elkayam
 
PDF
Oracle Database In-Memory Meets Oracle RAC
Markus Michalewicz
 
PPTX
Oracle Database in-Memory Overivew
Maria Colgan
 
PDF
In Memory Database In Action by Tanel Poder and Kerry Osborne
Enkitec
 
PDF
Oracle Database In-Memory Option in Action
Tanel Poder
 
PPTX
GLOC Keynote 2014 - In-memory
Connor McDonald
 
PDF
Adding real time reporting to your database oracle db in memory
Zohar Elkayam
 
PPTX
In memory databases presentation
Michael Keane
 
PPTX
Oracle Database In-Memory & Multitenant - TROUG Days'16 Istanbul
Mahir M. Quluzade
 
PDF
Oracle12c Database in-memory Data Sheet
Oracle
 
PDF
Larry Ellison Introduces Oracle Database In-Memory
OracleCorporate
 
PPTX
P9 speed of-light faceted search via oracle in-memory option by alexander tok...
Alexander Tokarev
 
PDF
Sap technical deep dive in a column oriented in memory database
Alexander Talac
 
PPT
Myth busters - performance tuning 101 2007
paulguerin
 
PDF
Intro to column stores
Justin Swanhart
 
Sloupcové uložení dat a použití in-memory technologií u řešení Exadata
MarketingArrowECS_CZ
 
Geek Sync I Need for Speed: In-Memory Databases in Oracle and SQL Server
IDERA Software
 
12c In Memory Management - Saurabh Gupta
pasalapudi123
 
Oracle in-Memory Column Store for BI
Franck Pachot
 
Oracle Database In-Memory and the Query Optimizer
Christian Antognini
 
Oracle Database In-Memory Option for ILOUG
Zohar Elkayam
 
Oracle Database In-Memory Meets Oracle RAC
Markus Michalewicz
 
Oracle Database in-Memory Overivew
Maria Colgan
 
In Memory Database In Action by Tanel Poder and Kerry Osborne
Enkitec
 
Oracle Database In-Memory Option in Action
Tanel Poder
 
GLOC Keynote 2014 - In-memory
Connor McDonald
 
Adding real time reporting to your database oracle db in memory
Zohar Elkayam
 
In memory databases presentation
Michael Keane
 
Oracle Database In-Memory & Multitenant - TROUG Days'16 Istanbul
Mahir M. Quluzade
 
Oracle12c Database in-memory Data Sheet
Oracle
 
Larry Ellison Introduces Oracle Database In-Memory
OracleCorporate
 
P9 speed of-light faceted search via oracle in-memory option by alexander tok...
Alexander Tokarev
 
Sap technical deep dive in a column oriented in memory database
Alexander Talac
 
Myth busters - performance tuning 101 2007
paulguerin
 
Intro to column stores
Justin Swanhart
 
Ad

Recently uploaded (20)

PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PPTX
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
PPTX
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
PPTX
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
PDF
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PDF
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PPTX
Digital Circuits, important subject in CS
contactparinay1
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PDF
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
PDF
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
Digital Circuits, important subject in CS
contactparinay1
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 

Oracle Database InMemory

  • 1. Do’s and Don’ts of Oracle Database In-Memory Jorge Barba Infrastructure Principal at Accenture Enkitec Group https://jorgebarbablog.wordpress.com Email: [email protected] Mar 2016
  • 2. Agenda 2 A. Overview B. Configuration C. Optimizer D. Queries E. Usage with Oracle Technologies F. Do's and Don'ts G. Conclusion
  • 4. 4 Database In-Memory In-Memory Column Store is an optional, static SGA pool that stores segments in columnar format. It is a supplement to the Buffer Cache. The database keeps the columnar data transactionally consistent with the Buffer Cache.
  • 5. 5 Row Format vs. Column Format Transactions run faster on row format Example: Query or Insert a sales order Fast processing a few rows, many columns. Analytics run faster on column format Example: Report on sales totals by region Fast accessing few columns, many rows
  • 6. 6 Dual Format Database Same table on both formats Analytics use the new in-memory Column Format OLTP uses the Row Format
  • 7. 7 Scanning Memory Buffer Cache Have to walk along that row until we find col4. IM Column Store Go directly to the col4 structure and scan all the entries.
  • 8. 8 Storage Index Storage Indexes Automatically created and maintained for each column in the Column Store. Allow data pruning based on filter predicates in the SQL statement. Keeps track of minimum and maximum values for each column in an IMCU. If the column value is outside the minimum and maximum range for an IMCU, the scan of that IMCU is avoided.
  • 9. 9 In-Memory Join and Bloom Filter (BF) •  A Bloom filter transforms a join into a filter that can be applied as part of the scan of the larger table. •  Very efficiently applied to column format data via SIMD vector processing. •  Appears in two places, at creation time and again when it is applied. SELECT count(*) FROM lineorder lo, part p WHERE lo.lo_partkey=p.p_partkey AND lo.lo_shipmode='TRUCK' AND lo.lo_ordtotalprice between 55000000 and 56000000 AND p.p_name='papaya burlywood’;
  • 10. 10 Vector Group By •  New optimizer transformation introduced with Oracle 12.1.0.2.0. •  Find the total sales of footwear products in outlet stores. •  The combination of these two phases dramatically improves the efficiency of a multiple table join with complex aggregations. | 9 | KEY VECTOR (USE) | :KV0000 | 10 | KEY VECTOR (USE) | :KV0001
  • 11. 11 SIMD Single Instruction Multiple Data SIMD A set of column values are evaluated together in a single CPU instruction. Designed to maximize the number of column entries loaded and evaluated in a single CPU instruction. 8 entries are loaded into the register for evaluation.
  • 13. 13 Configuring the In-Memory Column Store Configuration •  INMEMORY_SIZE=1520M •  Minimum of 100M •  Part of the SGA •  Fixed size SQL> select * from v$sga; NAME VALUE -------------------- ---------- Fixed Size 2932632 Variable Size 587202664 Database Buffers 2097152000 Redo Buffers 13844480 In-Memory Area 1593835520 alter system set inmemory_size=1520M scope=spfile; shutdown immediate; startup
  • 14. 14 Populating the In-Memory Column Store ALTER TABLE lineorder INMEMORY; ALTER TABLE lineorder NO INMEMORY; CREATE TABLE customer … PARTITION BY LIST (PARTITION p1 …… INMEMORY, PARTITION p2 …… NO INMEMORY); Eligible segments are: •  Tables •  Partitions •  Subpartitions •  Materialized Views Not supported: •  IOTs, Hash clusters, Out of line LOBs.
  • 15. 15 Composition of In-Memory Area and DML SQL> select pool, alloc_bytes 2 from v$inmemory_area; POOL ALLOC_BYTES -------------- ----------- 1MB POOL 1274019840 64KB POOL 301989888
  • 16. 16 Composition of In-Memory Area and DML •  Bulk Data Loads •  Typically conducted as a direct path load. •  The size of the missing data will be visible in the BYTES_NOT_POPULATED column (V $IM_SEGMENTS). •  Partition Exchange Loads •  Partition big tables or fact tables. •  Transaction Processing •  Single row data change operations (DML) execute via the Buffer Cache.
  • 17. 17 Repopulation •  Oracle Database will repopulate an IMCU when the number of entries reaches a threshold. •  Repopulation is more frequent for IMCUs that are accessed frequently or have higher percentage of stale rows. •  Also the IMCO background process may also repopulate.
  • 18. 18 Overhead •  Keeping the IM Column Store transactionally consistent. •  Rate of change, compression level, location of the changed rows, type of operations being performed.
  • 20. 20 Optimizer 1.  In 12c the optimizer is fully aware of the In- Memory Column Store. This means that the optimizer will cost the read from the In- memory Column Store. 2.  Using the same statistics and also new In- Memory statistics
  • 21. 21 Optimizer 10053 trace SELECT /* opt_trace_test */ sum(lo_revenue) FROM lineorder lo, customer c WHERE lo.lo_custkey=c.c_custkey AND c_region='AFRICA'; column sql_text format a30 select sql_id, child_number, sql_text from v$sql where sql_text like '%opt_trace_test%'; SQL_ID ------------- 5b8n5m6gtx71r
  • 22. 22 Optimizer 10053 trace (cont) alter session set max_dump_file_size = unlimited; execute DBMS_SQLDIAG.DUMP_TRACE(- p_sql_id='5b8n5m6gtx71r', - p_child_number=0, - p_component='Optimizer', - p_file_id='TRACE_10053'); How to Obtain Tracing of Optimizer Computations (EVENT 10053) (Doc ID 225598.1) col value format a90 SELECT value FROM v$diag_info WHERE name='Default Trace File'; VALUE --------------------------------------------------------------------------------------- /u01/app/oracle/diag/rdbms/db_inst2/DBNAME/trace/DB_INST2_ora_130114_TRACE_10053.trc
  • 23. 23 Optimizer 10053 trace (cont) *************************************** BASE STATISTICAL INFORMATION *********************** Table Stats:: Table: CUSTOMER Alias: C #Rows: 120000 SSZ: 0 LGR: 0 #Blks: 1882 AvgRowLen: 107.00 NEB: 0 ChainCnt: 0.00 SPC: 0 RFL: 0 RNF: 0 CBK: 0 CHR: 0 KQDFLG: 1 #IMCUs: 1 IMCRowCnt: 120000 IMCJournalRowCnt: 3000 #IMCBlocks: 0 IMCQuotient: 1.000000 Column (#1): C_CUSTKEY(NUMBER) AvgLen: 5 NDV: 120000 Nulls: 0 Density: 0.000008 Min: 1.000000 Max: 120000.000000 *********************** Table Stats:: Table: LINEORDER Alias: LO #Rows: 23996670 SSZ: 0 LGR: 0 #Blks: 335060 AvgRowLen: 96.00 NEB: 0 ChainCnt: 0.00 SPC: 0 RFL: 0 RNF: 0 CBK: 0 CHR: 0 KQDFLG: 1 #IMCUs: 23 IMCRowCnt: 23996670 IMCJournalRowCnt: 599917 #IMCBlocks: 0 IMCQuotient: 1.000000 Column (#3): LO_CUSTKEY(NUMBER) AvgLen: 5 NDV: 80504 Nulls: 0 Density: 0.000012 Min: 1.000000 Max: 119999.000000
  • 24. 24 Disabling and Enabling In-Memory To disable In-Memory scans set the parameter INMEMORY_QUERY = DISABLE Plans will get the cost based on disk statistics and scans will be from the IM Column Store. Use hint INMEMORY to force In-Memory Scan even if INMEMORY_QUERY is disabled. NO_INMEMORY disables In-Memory scan even if the table is in the In-Memory Column Store. SELECT /*+ INMEMORY */ sum(lo_revenue) FROM lineorder lo, customer c WHERE lo.lo_custkey=c.c_custkey AND c_region='AFRICA’; SELECT /*+ NO_INMEMORY */ sum(lo_revenue) FROM lineorder lo, customer c WHERE lo.lo_custkey=c.c_custkey AND c_region='AFRICA’;
  • 25. 25 Optimizer Summary •  In 12.1.0.2 the Optimizer is In-Memory aware. •  In-Memory statistics automatically generated at parse. •  Cost model adjusted for costing In-Memory Scans •  New INMEMORY and NO_INMEMORY hints
  • 27. 27 Queries •  We have chosen some of the queries that are candidates to benefit from Database In- Memory.
  • 28. 28 Function MAX(column) select max(lo_ordtotalprice) from lineorder; MAX(LO_ORDTOTALPRICE) --------------------- 55903140 Elapsed time: 0.004 select /*+ NO_INMEMORY */ max(lo_ordtotalprice) from lineorder; MAX(LO_ORDTOTALPRICE) --------------------- 55903140 Elapsed time: 4.014
  • 29. 29 Function MAX(column) B-tree index on lo_ordtotalprice create index ordtotalprice_ix on lineorder(lo_ordtotalprice); select /*+ NO_INMEMORY */ max(lo_ordtotalprice) from lineorder; MAX(LO_ORDTOTALPRICE) --------------------- 55903140 Elapsed time: 0.001
  • 30. 30 Function MAX(column) How about Result Cache? SQL show parameter result_cache_max_size big integer 22000K select /*+ RESULT_CACHE */ max(lo_ordtotalprice) from lineorder; MAX(LO_ORDTOTALPRICE) --------------------- 55903140 Elapsed time: 0.001
  • 31. 31 How do we know it used the In-Memory Column Store? select n.name, s.value from v$mystat s, v$statname n where s.statistic#=n.statistic# and n.name like 'IM scan CUs columns accessed'; ----------------------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | ----------------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | 3 | 2224 (12)| 00:00:01 | | 1 | SORT AGGREGATE | | 1 | 3 | | | | 2 | TABLE ACCESS INMEMORY FULL| LINEORDER | 24M| 68M| 2224 (12)| 00:00:01 | ----------------------------------------------------------------------------------------- NAME VALUE ---------------------------------------------------------------- ---------- IM scan CUs columns accessed 45
  • 32. 32 One equality predicate SELECT lo_orderkey, lo_custkey, lo_revenue FROM lineorder WHERE lo_orderkey = 4000000; LO_ORDERKEY LO_CUSTKEY LO_REVENUE ----------- ----------- ----------- 4000000 51832 6983797 4000000 51832 917952 4000000 51832 2501733 4000000 51832 7895007 Elapsed time: 0.002 SELECT /*+ NO_INMEMORY */ lo_orderkey, lo_custkey, lo_revenue FROM lineorder WHERE lo_orderkey = 4000000; LO_ORDERKEY LO_CUSTKEY LO_REVENUE ----------- ----------- ----------- 4000000 51832 6983797 4000000 51832 917952 4000000 51832 2501733 4000000 51832 7895007 Elapsed time: 4.528 IM scan CUs columns accessed 3 IM scan segments minmax eligible 44 IM scan CUs pruned 43
  • 33. 33 One equality predicate B-tree index on lo_orderkey create index lo_orderkey_ix on lineorder (lo_orderkey); SELECT /*+ NO_INMEMORY */ lo_orderkey, lo_custkey, lo_revenue FROM lineorder WHERE lo_orderkey = 4000000; LO_ORDERKEY LO_CUSTKEY LO_REVENUE ----------- ----------- ----------- 4000000 51832 6983797 4000000 51832 917952 4000000 51832 2501733 4000000 51832 7895007 Elapsed time: 0.001
  • 34. 34 Three equality predicate SELECT lo_orderkey, lo_custkey, lo_revenue FROM lineorder WHERE lo_custkey = 13286 AND lo_shipmode = 'TRUCK’ AND lo_orderpriority = '3-MEDIUM’; LO_ORDERKEY LO_CUSTKEY LO_REVENUE ----------- ----------- ----------- 8268262 13286 6777268 8268262 13286 6207689 9048868 13286 6394887 17521920 13286 2905822 19397281 13286 3573400 Elapsed time: 0.002 SELECT /*+ NO_INMEMORY */ lo_orderkey, lo_custkey, lo_revenue FROM lineorder WHERE lo_custkey = 13286 AND lo_shipmode = 'TRUCK’ AND lo_orderpriority = '3-MEDIUM’; LO_ORDERKEY LO_CUSTKEY LO_REVENUE ----------- ----------- ----------- 8268262 13286 6777268 8268262 13286 6207689 9048868 13286 6394887 17521920 13286 2905822 19397281 13286 3573400 Elapsed time: 4.868 IM scan CUs columns accessed 3 IM scan segments minmax eligible 44 IM scan CUs pruned 43
  • 35. 35 How about composite index? create index cust_ship_pri_ix on lineorder (lo_custkey, lo_shipmode, lo_orderpriority); SELECT /*+ NO_INMEMORY */ lo_orderkey, lo_custkey, lo_revenue FROM lineorder WHERE lo_custkey = 13286 AND lo_shipmode = 'TRUCK’ AND lo_orderpriority = '3-MEDIUM’; Customer#000118324 JORDAN Customer#000119371 ETHIOPIA Customer#000119386 SAUDI ARABIA Customer#000118412 VIETNAMLO_ORDERKEY LO_CUSTKEY LO_REVENUE ----------- ----------- ----------- 8268262 13286 6777268 8268262 13286 6207689 9048868 13286 6394887 17521920 13286 2905822 19397281 13286 3573400 Elapsed time: 0.001
  • 36. 36 Greater Than () Instead of Equality (=) SELECT MAX(lo_ordtotalprice) FROM lineorder WHERE lo_quantity 74; Elapsed time: 0.002 SELECT MAX(lo_ordtotalprice) FROM lineorder WHERE lo_quantity 74; Elapsed time: 4.82 IM scan CUs columns accessed 3 IM scan segments minmax eligible 44 IM scan CUs pruned 43
  • 37. 37 How about an index? create index lo_quantity_ix on lineorder(lo_quantity); SELECT /*+ INDEX(a lo_quantity_ix) */ MAX(lo_ordtotalprice) FROM lineorder a WHERE lo_quantity 74; Elapsed time: 0.001
  • 38. 38 Bloom Filter Example SELECT c.c_name, c.c_nation FROM customer c, part p, lineorder lo WHERE lo.lo_custkey = c.c_custkey AND lo.lo_partkey = p.p_partkey AND p.p_name = 'white salmon'; C_NAME C_NATION ------------------------- --------------- Customer#000118324 JORDAN Customer#000119371 ETHIOPIA Customer#000119386 SAUDI ARABIA Customer#000118412 VIETNAM ... ...
  • 39. 39 Vector Group By Example SELECT /*+ VECTOR_TRANSFORM */ c.c_name, c.c_nation, sum(lo_ordtotalprice) FROM customer c, part p, lineorder lo WHERE lo.lo_custkey = c.c_custkey AND lo.lo_partkey = p.p_partkey AND p.p_name = 'white salmon' group by c.c_name, c.c_nation; ... ... C_NAME C_NATION SUM(LO_ORDTOTALPRICE) ------------------------- --------------- --------------------- Customer#000118540 ROMANIA 12634439 Customer#000119051 ARGENTINA 28032775 Customer#000118129 JAPAN 22258279 Customer#000118198 UNITED STATES 17849279
  • 40. Usage with Oracle Technologies
  • 41. 41 RAC Each node in a RAC environment has its own IM column store. Objects populated into memory will be distributed across all of the IM column stores in the cluster. ALTER TABLE lineorder INMEMORY DISTRIBUTE BY PARTITION; ALTER TABLE lineorder INMEMORY DISTRIBUTE AUTO DUPLICATE ALL;
  • 42. 42 M6-32 M6-32 SMP removes the overhead of distributing queries across a cluster and coordinating transactions. Algorithms NUMA optimized. Memory interconnect far faster than any network.
  • 43. 43 Exadata Exadata Complete fault-tolerant In-Memory solution. Exceed DRAM limits and transparently scale across Memory, Flash and Disk. Initial population of data into the In- Memory column store from storage is very fast. The In-Memory Aggregation optimization, can be offloaded to Exadata storage cells
  • 44. 44 Oracle Technologies •  Data Guard •  Golden Gate •  Oracle Multitenant •  Partitioning •  Parallelism •  Resource Manager •  RMAN •  ALTER TABLE EXCHANGE
  • 45. 45 Partition Exchange 1.  Create external table for flat files 2.  Use CTAS to create non part table and gather table stats 3.  Set INMEMORY attribute ON 4.  Populate non part table in column store 5.  Alter table table_name exchange partition part name with table non part table;
  • 47. 47 The benefits of IM Column Store Speed up Scans, Joins, Aggregates. Scan of large tables and using predicates like =, , , IN Querying a subset of columns in a table, for example, selecting 5 of 100 columns. Accelerating joins by converting predicates on small dimension tables into filters on a large fact table.
  • 48. 48 Do or Don’t? Business applications Ad-hoc analytic queries Data warehouse workloads
  • 49. 49 Do or Don’t? OLTP databases short transactions using index lookups
  • 50. 50 Do Queries that scan a large number of rows and apply filters that use operators such as the following: =, , , and IN. Queries that select a small number of columns from a table or materialized view with a large number of columns, such as a query that selects five columns from a table with 100 columns. Queries that join a small table to a large table. Queries that aggregate data.
  • 51. 51 Don’t Queries with complex predicates. Queries that select a large number of columns. Queries that return a large number of rows. Queries with multiple large table joins.
  • 52. 52 Don’t In-memory speeds up analytic data access, not: Network round trips, logon/logoff Parsing, PL/SQL, complex functions Data processing (as opposed to access) Complex joins or aggregations where not much data is filtered before processing Load and select once - Staging tables, ETL, temp tables
  • 53. Is it for me? Conclusion
  • 54. 54 KEEP CALM AND ASK ME Tú Pregúntame … Please visit my blog at: https://jorgebarbablog.wordpress.com Email: [email protected]