oracle database in-memory & multitenant - troug days'16 istanbul

46
Insert Picture Here April 28-29, 201 Oracle Database In-Memory & Multitenant Mahir M. Quluzade

Upload: mahir-m-quluzade

Post on 16-Apr-2017

1.258 views

Category:

Data & Analytics


0 download

TRANSCRIPT

Page 1: Oracle Database In-Memory & Multitenant - TROUG Days'16 Istanbul

Insert Picture Here

April 28-29, 2016Oracle Database In-Memory & MultitenantMahir M. Quluzade

Page 2: Oracle Database In-Memory & Multitenant - TROUG Days'16 Istanbul

2 Oracle Database In-Memory - Mahir M. Quluzade © 2016 http://www.mahir-quluzade.com

Mahir M. Quluzade

Oracle ACE AZEROUG (Azerbaijan Oracle User Group) TROUG (Turkish Oracle User Group) OCE 12c, 11g Author of OTech Magazine and OTN Articles Central Bank - Oracle DBA Oracle Blog : http//www.mahir-quluzade.com

Page 3: Oracle Database In-Memory & Multitenant - TROUG Days'16 Istanbul

3 Oracle Database In-Memory - Mahir M. Quluzade © 2016 http://www.mahir-quluzade.com

What isOracle Multitenant?

Page 4: Oracle Database In-Memory & Multitenant - TROUG Days'16 Istanbul

4 Oracle Database In-Memory - Mahir M. Quluzade © 2016 http://www.mahir-quluzade.com

Oracle Database Architecture

Oracle Instance– SGA & PGA – Background Processes

Oracle Database – Control Files– Data Files – Redo Logs (Online and Archived)– Parameter and Password file

Pre-12c Oracle Database

Database ServerMemory

BackgroundProcesses

DatabaseFiles

Page 5: Oracle Database In-Memory & Multitenant - TROUG Days'16 Istanbul

5 Oracle Database In-Memory - Mahir M. Quluzade © 2016 http://www.mahir-quluzade.com

Oracle Database ArchitectureRequires memory, processes and database files

System Resources

ERPMemory

BackgroundProcesses

DatabaseFiles

CRMMemory

BackgroundProcesses

DatabaseFiles

DWMemory

BackgroundProcesses

DatabaseFiles

Page 6: Oracle Database In-Memory & Multitenant - TROUG Days'16 Istanbul

6 Oracle Database In-Memory - Mahir M. Quluzade © 2016 http://www.mahir-quluzade.com

Container Database

New Multitenant ArchitectureMemory and processes required at multitenant container level only

System Resources

ERPMemory

BackgroundProcesses

DatabaseFiles

CRMMemory

BackgroundProcesses

DatabaseFiles

DWMemory

BackgroundProcesses

DatabaseFiles

Page 7: Oracle Database In-Memory & Multitenant - TROUG Days'16 Istanbul

7 Oracle Database In-Memory - Mahir M. Quluzade © 2016 http://www.mahir-quluzade.com

New Multitenant ArchitectureMemory and processes required at multitenant container level only

System Resources

Container Database

Page 8: Oracle Database In-Memory & Multitenant - TROUG Days'16 Istanbul

8 Oracle Database In-Memory - Mahir M. Quluzade © 2016 http://www.mahir-quluzade.com

Multitenant ArchitectureComponents of a Multitenant Container Database (CDB)

Multitenant Container DatabaseROOT

12.1

HCM12.1

DW12.1

CRM12.1

ERP12.1

Pluggable Databases (PDBs)

PDBs

Root

CDB

CREATE DATABASE … ENABLE PLUGGABLE DATABASE

Create CDB

CREATE PLUGGABLE DATABASE …Create PDB

Page 9: Oracle Database In-Memory & Multitenant - TROUG Days'16 Istanbul

9 Oracle Database In-Memory - Mahir M. Quluzade © 2016 http://www.mahir-quluzade.com

Multitenant Architecture – Dynamics

PDBs share common SGA andbackground processes

Foreground sessions see only the PDB they connect to

Page 10: Oracle Database In-Memory & Multitenant - TROUG Days'16 Istanbul

10 Oracle Database In-Memory - Mahir M. Quluzade © 2016 http://www.mahir-quluzade.com

What isOracle Database In-Memory?

Page 11: Oracle Database In-Memory & Multitenant - TROUG Days'16 Istanbul

11 Oracle Database In-Memory - Mahir M. Quluzade © 2016 http://www.mahir-quluzade.com

Oracle Database In-Memory Goals

Page 12: Oracle Database In-Memory & Multitenant - TROUG Days'16 Istanbul

12 Oracle Database In-Memory - Mahir M. Quluzade © 2016 http://www.mahir-quluzade.com

Breakthrough: Dual Format Database

Page 13: Oracle Database In-Memory & Multitenant - TROUG Days'16 Istanbul

13 Oracle Database In-Memory - Mahir M. Quluzade © 2016 http://www.mahir-quluzade.com

What is changed in Oracle Instance?

Page 14: Oracle Database In-Memory & Multitenant - TROUG Days'16 Istanbul

14 Oracle Database In-Memory - Mahir M. Quluzade © 2016 http://www.mahir-quluzade.com

What is changed in Oracle Instance?

SGA - System Global Area– Buffer Cache– Shared Pool– Redo Buffer– Large Pool– Other Memory Areas– In-Memory Area

Background Processes– DBWn– LGWR– …– Wnnn (worker processes ora_w00n_db_name)

Page 15: Oracle Database In-Memory & Multitenant - TROUG Days'16 Istanbul

15 Oracle Database In-Memory - Mahir M. Quluzade © 2016 http://www.mahir-quluzade.com

In-Memory Area

Contains two sub-pools: – IMCU pool: Stores In Memory Compression Units (IMCUs)

– SMU pool: Stores Snapshot Metadata Units (SMUs)

IMCUs contain column formatted data SMUs contain metadata and transactional

information

In-Memory area is static area– 1MB Pool – Populated Columns Data– 64KB Pool – Objects Metadata

Page 16: Oracle Database In-Memory & Multitenant - TROUG Days'16 Istanbul

16 Oracle Database In-Memory - Mahir M. Quluzade © 2016 http://www.mahir-quluzade.com

How to install and configure Oracle Database In-Memory?

Page 17: Oracle Database In-Memory & Multitenant - TROUG Days'16 Istanbul

17 Oracle Database In-Memory - Mahir M. Quluzade © 2016 http://www.mahir-quluzade.com

Oracle Database In-Memory automatically installed as part of Oracle Database 12c Release 1 (12.1.0.2)

But not enabled by default

Installing: Oracle Database In-Memory

Page 18: Oracle Database In-Memory & Multitenant - TROUG Days'16 Istanbul

19 Oracle Database In-Memory - Mahir M. Quluzade © 2016 http://www.mahir-quluzade.com

In-Memory Area

In-Memory control parameters starting “INMEMORY_” prefix Additional for optimizer control parameter OPTIMIZER_INMEMORY_AWARE

Core Initialization Parameters

Page 19: Oracle Database In-Memory & Multitenant - TROUG Days'16 Istanbul

20 Oracle Database In-Memory - Mahir M. Quluzade © 2016 http://www.mahir-quluzade.com

Starting in Oracle Database 12c Release 2 (12.2), can increase INMEMORY_SIZE size dynamically by using ALTER SYSTEM. If free memory is available in the SGA, then the database allocates the memory to the IM column store.

Note: You cannot use ALTER SYSTEM to reduce INMEMORY_SIZE.

Enable In-Memory Area

SQL> alter system set memory_max_target=1324M scope=spfile;

SQL> alter system set inmemory_size=300M scope=spfile;

SQL> shutdown immediate;

SQL> startup ORACLE instance started. Total System Global Area 1392508928 bytes Fixed Size 2924304 bytes Variable Size 1040187632 bytes Database Buffers 16777216 bytes Redo Buffers 13852672 bytesIn-Memory Area 318767104 bytes Database mounted. Database opened.

Page 20: Oracle Database In-Memory & Multitenant - TROUG Days'16 Istanbul

21 Oracle Database In-Memory - Mahir M. Quluzade © 2016 http://www.mahir-quluzade.com

How to configure In-Memory in Multitenant Container Database?

Page 21: Oracle Database In-Memory & Multitenant - TROUG Days'16 Istanbul

22 Oracle Database In-Memory - Mahir M. Quluzade © 2016 http://www.mahir-quluzade.com

Parameters in Multitenant Container Database

V$SYSTEM_PARAMETERS.ISPDB_MODIFIABLE

Page 22: Oracle Database In-Memory & Multitenant - TROUG Days'16 Istanbul

23 Oracle Database In-Memory - Mahir M. Quluzade © 2016 http://www.mahir-quluzade.com

Parameters in Multitenant Container Database

Page 23: Oracle Database In-Memory & Multitenant - TROUG Days'16 Istanbul

24 Oracle Database In-Memory - Mahir M. Quluzade © 2016 http://www.mahir-quluzade.com

INMEMORY attributes in DDLs

Page 24: Oracle Database In-Memory & Multitenant - TROUG Days'16 Istanbul

25 Oracle Database In-Memory - Mahir M. Quluzade © 2016 http://www.mahir-quluzade.com

Populating In-Memory Colum Store

SQL> CREATE TABLESAPCE users DATAFILE … INMEMORY;

SQL> ALTER TABLESPACE users INMEMORY;

– All new tables and materialized views in this tablespace will be enabled for IM column store by default.

INMEMORY attribute for Tablespaces

Page 25: Oracle Database In-Memory & Multitenant - TROUG Days'16 Istanbul

26 Oracle Database In-Memory - Mahir M. Quluzade © 2016 http://www.mahir-quluzade.com

Populating In-Memory Colum Store

SQL> CREATE TABLE orders (ID NUMBER, …) INMEMORY;

SQL> ALTER TABLE orders INMEMORY;

Can exclude one or more not important columns for aggregation– SQL> ALTER TABLE orders INMEMORY NO INMEMORY(createuser_id);

Can disable IM Column Store for one or more partition– SQL> ALTER TABLE orders MODIFY PARTITION orders_p2000 NO INMEMORY;

INMEMORY attribute for Tables

Page 26: Oracle Database In-Memory & Multitenant - TROUG Days'16 Istanbul

27 Oracle Database In-Memory - Mahir M. Quluzade © 2016 http://www.mahir-quluzade.com

Populating In-Memory Colum Store

SQL> CREATE MATERIALIZED VIEW sales_mv INMEMORY SELECT * FROM SALES;

SQL> SELECT table_name, inmemory, inmemory_priority, inmemory_distribute,

inmemory_compression FROM user_tables WHERE table_name = ‘SALES_MV'; TABLE_NAME INMEMORY INMEMORY_PRI INMEMORY_DISTRI INMEMORY_COMPRESS ---------- -------- ------------ --------------- ------------------- SALE_MV ENABLED NONE AUTO FOR QUERY LOW

INMEMORY attribute for Materialized Views

Page 27: Oracle Database In-Memory & Multitenant - TROUG Days'16 Istanbul

28 Oracle Database In-Memory - Mahir M. Quluzade © 2016 http://www.mahir-quluzade.com

Populating In-Memory Colum Store

CRITICAL– Object is populated immediately after the database is opened

HIGH MEDIUM LOW NONE (default)

– Object only populated after they are scanned for the first time, if space available.

Controlled by the PRIORITY sub-clause of the INMEMORY clause

SQL> ALTER TABLE customers INMEMORY PRIORITY HIGH;

Page 28: Oracle Database In-Memory & Multitenant - TROUG Days'16 Istanbul

29 Oracle Database In-Memory - Mahir M. Quluzade © 2016 http://www.mahir-quluzade.com

In-Memory Compression Levels

NO MEMCOMPRESS… Data is populated without any compression

MEMCOMPRESSION FOR DML … Minimal compression optimized for DML performance

MEMCOMPRESSION FOR QUERY LOW … Optimized for query performance (default)

MEMCOMPRESSION FOR QUERY HIGH… Optimized for query performance as well as space saving

MEMCOMPRESSION FOR CAPACITY LOW … Balanced with a greater bias towards as space saving

MEMCOMPRESSION FOR CAPACITY HIGH … Optimized for space saving

Controlled by the MEMCOMPRESS sub-clause of INMEMORY clause

Page 29: Oracle Database In-Memory & Multitenant - TROUG Days'16 Istanbul

30 Oracle Database In-Memory - Mahir M. Quluzade © 2016 http://www.mahir-quluzade.com

In-Memory Compression LevelsControlled by the MEMCOMPRESS sub-clause of INMEMORY clause

SQL> ALTER TABLE customers INMEMORY 2 MEMCOMPRESSION NO

COMPRESSION;

SQL> ALTER TABLE customers INMEMORY 2 MEMCOMPRESSION FOR CAPACITY

LOW;

Page 30: Oracle Database In-Memory & Multitenant - TROUG Days'16 Istanbul

31 Oracle Database In-Memory - Mahir M. Quluzade © 2016 http://www.mahir-quluzade.com

In-Memory Compression Levels

Use DBMS_COMPRESSION

Applies MEMCOMPRESS to sample set of data from a table

Returns estimated compression ratio

Controlled by the MEMCOMPRESS sub-clause of INMEMORY clause

Page 31: Oracle Database In-Memory & Multitenant - TROUG Days'16 Istanbul

32 Oracle Database In-Memory - Mahir M. Quluzade © 2016 http://www.mahir-quluzade.com

In-Memory Column Store for RAC

Each node in RAC have IM Column Store– Same size recommended– Object by default distributed across all nodes

DISTRIBUTE BY ROWID RANGE DISTRIBUTE BY PARTITION DISTRIBUTE BY SUBPARTITION

– Consists of 1 IMCU objects distribute only one node

Populate same object to IM Column Store on

every nodes– Supported only Engineered Systems – EXADATA– Using DUPLICATE clause

SQL> ALTER TABLE orders INMEMORY 2 DISTRIBUTE BY PARTITION;

SQL> ALTER TABLE orders INMEMORY 2 DUPLICATE ALL;

Page 32: Oracle Database In-Memory & Multitenant - TROUG Days'16 Istanbul

33 Oracle Database In-Memory - Mahir M. Quluzade © 2016 http://www.mahir-quluzade.com

How Does Database In-Memory Improve Performance?

Page 33: Oracle Database In-Memory & Multitenant - TROUG Days'16 Istanbul

34 Oracle Database In-Memory - Mahir M. Quluzade © 2016 http://www.mahir-quluzade.com

Querying the In-Memory Column Store

Compressed Columnar Storage SIMD Vector Processing In-Memory Storage Indexes In-Memory Joins and Aggregations

Page 34: Oracle Database In-Memory & Multitenant - TROUG Days'16 Istanbul

35 Oracle Database In-Memory - Mahir M. Quluzade © 2016 http://www.mahir-quluzade.com

Compressed Columnar Storage

Compressed Column Units allows an analytic query scan only data within the required column

Page 35: Oracle Database In-Memory & Multitenant - TROUG Days'16 Istanbul

36 Oracle Database In-Memory - Mahir M. Quluzade © 2016 http://www.mahir-quluzade.com

The column format used in the IM column store has been specifically designed to maximize the number of column entries that can be loaded into the vector registers on the CPU and evaluated in a single CPU instruction

Each CPU core scans local in-memory columns Scans use super fast SIMD vector instructions

– Originally designed for graphics & science

Billions of rows/sec scan rate per CPU core – Row format is millions/sec

SIMD vector processing allows a set of column values to be evaluated together in a single CPU instruction

SIMD Vector Processing

Page 36: Oracle Database In-Memory & Multitenant - TROUG Days'16 Istanbul

37 Oracle Database In-Memory - Mahir M. Quluzade © 2016 http://www.mahir-quluzade.com

In-Memory Storage Indexes

Each column is the made up of multiple column units

Min / max value is recorded for each column unit in a storage index

Storage index provides partition pruning like performance for ALL queries

Page 37: Oracle Database In-Memory & Multitenant - TROUG Days'16 Istanbul

38 Oracle Database In-Memory - Mahir M. Quluzade © 2016 http://www.mahir-quluzade.com

In-Memory Joins

Bloom filters enable joins to be converted into fast column scans

Tried and true technology originally released in 10g

Same technique used to offload joins on Exadata

Page 38: Oracle Database In-Memory & Multitenant - TROUG Days'16 Istanbul

39 Oracle Database In-Memory - Mahir M. Quluzade © 2016 http://www.mahir-quluzade.com

In-Memory JoinsExample

SQL> SELECT * 2 FROM customer c, 3 orders o 4 WHERE c.id = o.customer_id

Page 39: Oracle Database In-Memory & Multitenant - TROUG Days'16 Istanbul

40 Oracle Database In-Memory - Mahir M. Quluzade © 2016 http://www.mahir-quluzade.com

In-Memory Aggregations

Without need to support objects such as indexes, summary tables and materialized views

New SQL Execution Operations– KEY VECTOR and VECTOR GROUP BY

Indicate plan is a vector transformation plan

Vector transformation plan designed for– Optimize queries involving aggregation and joins large

fact and multiple small dimension tables

– working with Star Queries

Page 40: Oracle Database In-Memory & Multitenant - TROUG Days'16 Istanbul

41 Oracle Database In-Memory - Mahir M. Quluzade © 2016 http://www.mahir-quluzade.com

In-Memory Aggregations

Vector Transformation Plan supports – Aggregation operators :

SUM, AVERAGE, MIN, MAX, STD and VARIANCE COUNT DISTINCT operations not supported by VECTOR GROUP BY

– The grouping syntax used in query is GROUP BY GROUPING SETS, GROUP BY ROLLUP not currently supported

– All joins must be equijoins Multiple columns of dimension table join the fact table with same join type

and same data type (for best performance, not be wrapped in a fuction )

Page 41: Oracle Database In-Memory & Multitenant - TROUG Days'16 Istanbul

42 Oracle Database In-Memory - Mahir M. Quluzade © 2016 http://www.mahir-quluzade.com

Vector Transformation Plan

SQL> SELECT t.calendar_year, 2 p.prod_category, 3 SUM(quantity_sold) 4 FROM times t, 5 products p, 6 sales f 7 WHERE t.time_id = f.time_id 8 AND p.prod_id = f.prod_id 9 GROUP BY t.calendar_year, 10 p.prod_category;

Example

Page 42: Oracle Database In-Memory & Multitenant - TROUG Days'16 Istanbul

43 Oracle Database In-Memory - Mahir M. Quluzade © 2016 http://www.mahir-quluzade.com

What’scoming with Oracle Database 12.2?

Page 43: Oracle Database In-Memory & Multitenant - TROUG Days'16 Istanbul

44 Oracle Database In-Memory - Mahir M. Quluzade © 2016 http://www.mahir-quluzade.com

What is coming with Oracle Database 12.2 ?

Starting in Oracle Database 12c Release 2 (12.2), can increase INMEMORY_SIZE size dynamically by using ALTER SYSTEM.

In-Memory Expressions (IM expressions)– IM expressions populate the results of frequently evaluated query expressions into the In-Memory

Column Store. A candidate for an IM expression might be (monthly_sales*12)/52.

In-Memory virtual columns (IM virtual columns)– IM virtual columns enable the IM column store to materialized some or all virtual columns on a table.

Active Data Guard will Support In-Memory

In-Memory Enhancements

Page 44: Oracle Database In-Memory & Multitenant - TROUG Days'16 Istanbul

45 Oracle Database In-Memory - Mahir M. Quluzade © 2016 http://www.mahir-quluzade.com

Additional Information

• Oracle Database 12c Release 12.1.0.2 Documentation• Oracle Database In-Memory White Paper • Oracle Database In-Memory Aggregation Paper • When to use Oracle Database In-Memory

Page 45: Oracle Database In-Memory & Multitenant - TROUG Days'16 Istanbul

46 Oracle Database In-Memory - Mahir M. Quluzade © 2016 http://www.mahir-quluzade.com

Your Questions

http://www.mahir-quluzade.com

http://www.youtube.com/mahoora

https://twitter.com/marzade

https://www.linkedin.com/in/mahirquluzade

https://www.facebook.com/mahir.quluzade

Contacts

Page 46: Oracle Database In-Memory & Multitenant - TROUG Days'16 Istanbul

47 Oracle Database In-Memory - Mahir M. Quluzade © 2016 http://www.mahir-quluzade.com

Thank you!