You are on page 1of 179

The Best Oracle

12c New Features


Rich Niemiec

October 21, 2015

Oracle Disclaimer: The following is intended to outline Oracle's general product direction. It is intended for information purposes only, and may
not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in
making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle's products remains at
the sole discretion of Oracle.
(Thanks: Kay Cavender, Michelle Kolbe, Lori Lorusso, Andy Mendelsohn, Debbie Migliore, Maria Colgan, Penny Avril, Deba Chatterjee, Dan Koloski, Jagan Athreya, Werner De Gruyter, Julian Dontcheff, Jacob & Lucas Niemiec)

October 21, 2015

My Presentations at OpenWorld 2015


Sunday:
12c Best New Features
12c Best Tuning Features

9:00 9:45 AM MS 305


11:00 - 11:45 AM MS 304

Monday:
The Best 12c Database Features 10:30 - 11:00 AM Rolta Booth #1701
Enter to Win an iPad Air
Tuesday:
Innovation, Big Data & IOT Brief 3:15 3:35 PM Rolta Booth #1701
Enter to Win an iPad Air
Wednesday:

Innovation, Big Data & IOT 1:45 - 2:30 PM MS 103


October 21, 2015

All Booth Presentations at Rolta Booth # 1701 in Moscone South Vendor Hall

Richs Overview
@richniemiec

President, Oracle Consulting, Americas & Advisor to Rolta Intl.


Board
Board Member TEC, Ask DB Experts, Fretzel
Former CEO of TUSC

Inc. 500 Company (Fastest Growing 500 Private Companies)


10 Offices in the United States (U.S.); Based in Chicago
Oracle Advantage Partner in Tech & Applications

Former President Rolta TUSC & President Rolta EICT


International
Author (4 Oracle Best Sellers #1 Oracle Tuning Book for two
Decades):

Oracle Performing Tips & Techniques (Covers Oracle7 & 8i)


Oracle9i & 10g Performance Tips & Technique
Oracle Database 11g Performance Tips & Techniques

October 21, 2015

Former President of the International Oracle Users Group


Current President of the Midwest Oracle Users Group
Chicago Entrepreneur Hall of Fame - 1998

E&Y Entrepreneur of the Year & National Hall of Fame - 2001


IOUG Top Speaker in 1991, 1994, 1997, 2001, 2006, 2007
MOUG Top Speaker Twelve Times
National Trio Achiever award - 2006

Oracle Certified Master & Oracle Ace Director


Purdue Outstanding Electrical & Computer and Engineer 2007

Redefining Value & Solutions for Customers

October 21, 2015

Passion for Technology, Commitment to Excellence


A Global 200 Forbes Best Companies under $1B
Revenue of 500M+ & 3500 employees globally
A top partner to Oracle, HP, EMC, VMware, & SAP
EBS, BI, EPM & Managed Services
2013
Rising Star
Award

Top 250
Partners

October 21, 2015

3500 employees globally

Audience Knowledge / Versions


Oracle7 Experience ?
Oracle8i Experience ?
Oracle9i Experience ?
Oracle10g Experience?
Oracle Database 11g R2 Experience?
Oracle Database 12c Experience?

October 21, 2015

Goals

Present NEW features in an EASY way


Focus on a few nice features of Oracle12c

Non-Goals

Learn ALL aspects of Oracle12c


Learn Tips that will make you an expert

The 10 Happiest Jobs in America

October 21, 2015

Overview 12c
Know the Oracle!
Start Me Up Using Memory Target, The Buffer
Cache & The Result Cache
Invisible Columns & Fetch First x Rows(12c) & virtual
columns (11g)
Multiple indexes on the same Column (12c) &
Invisible Indexes (11g)
Change Table Compression at import Time (12c)

October 21, 2015

Create Views as Tables (12c)


Pluggable Databases (12c)
Enhanced DDL Online (12c)
Automatic Diagnostics Repository (12c)
Security Enhancements (12c)
Big Data Briefly & In-Memory MapReduce
Oracle Database In-Memory (12c+ not released yet)
Other 12c New Features

Oracle Firsts Innovation to Acquisitions

October 21, 2015

1979 First commercial SQL RDBMS


1983 First 32-bit mode RDBMS
1984 First database with read consistency
1987 First client-server database
1994 First commercial and multilevel secure database evaluations
1995 First 64-bit mode RDBMS
1996 First to break the 30,000 TPC-C barrier
1997 First Web database
1998 First Database - Native Java Support; Breaks 100,000 TPC-C
1998 First Commercial RDBMS ported to Linux
2000 First database with XML
2001 First RDBMS with Real Application Clusters & First middle-tier database cache
2004 First True Grid DB & 2005 First FREE Oracle Database (10g Express Edition)
2006 First Oracle Support for LINUX Offering
2007 Oracle 11g Released!
2008 Exadata V1 Server Announced (Oracle buys BEA)
2009 Oracle buys Sun Java; MySQL; Solaris; Hardware; OpenOffice, StorageTek
2010 Oracle announces MySQL Cluster 7.1, Exadata, Exalogic, Americas Cup Win
2011 X2-2 Exadata, ODA, Exalytics, SuperCluster, Big Data, Cloud, Social Network
2012 X3-2 Exadata, Expanded Cloud Offerings, Solaris 11.1
2013 Oracle12c Released! Oracle X3-8 Exadata, Acquisitions (Acme Packetetc.)!
2014 Oracle X-4, Acquisitions: Responsys & Corente, IN-MEMORY DB (2015 X5-2)
2015 X5-2, X5-8, FS1 Flash Array, More Acquisitions & Cloud Solutions

10

Mark Hurd & Incredible Trends


Average age of Apps is 20 yearsback then

No Search
Few using the Internet
No Amazon
No Facebook
No Twitter

October 21, 2015

40% Data growth per year


90% of Data created in past two years
Big bank Now has 300P & growing at 40%
Mobile Retail is getting huge & may be most of the future
market
Oracle will spend $5B in R&D this year Leverage it!

11

Testing the Future Version


Version 12.1.0.0.1 of the Database
Version 11.2.0.1.0 of the Database for 11g R2 Examples

October 21, 2015

12

Oracle Database 12c Release 1: Upgrade Paths


Direct Upgrade Path

Source Database
10.2.0.5 (or higher)

Target Database
12.1.x

11.1.0.7 (or higher)

12.1.x

11.2.0.2 (or higher)

12.1.x
In-Direct Upgrade Path

Source Database

October 21, 2015

7.3.3.0.0 (or lower)


8.0.5.0.0 (or lower)
8.1.7.0.0 (or lower)
9.0.1.3.0 (or lower)

Upgrade Path for


Target Database
7.3.4.x --> 9.2.0.8
8.0.6.x --> 9.2.0.8
8.1.7.4 --> 9.2.0.8
9.0.1.4 --> 9.2.0.8

Target Database
11.2.x
11.2.x
11.2.x
11.2.x

13

Database Upgrade Assistant (DBUA)

More automation during the upgrade process


Additional validation steps (also for on-line)
Post upgrade more automated as well
Better status as to specific component success
Post upgrade fix-it scripts to help automate
future needs
Parallel upgrade takes advantage of multiple
CPU cores
Express Edition Upgrade to others (since 11g)
October 21, 2015

14

Database Upgrade Assistant (DBUA)


More automation during the upgrade process
Additional validation steps (also for on-line)
Post upgrade more automated as well
Better status as to specific component success
Post upgrade fix-it scripts to help automate future needs
Parallel upgrade takes advantage of multiple CPU cores
Express Edition Upgrade to others (since 11g)

October 21, 2015

15

Database Upgrade Assistant (DBUA)


DBUA checks before the upgrade:

Invalid user accounts or roles


Invalid data types or invalid objects
De-supported character sets
Adequate resources (rollback segments, tablespaces,
and free disk space)
Missing SQL scripts needed for the upgrade
Listener running (if Oracle Enterprise Manager Database
Control upgrade or configuration is requested)
Oracle Database software linked with Database Vault
option. If Database Vault is enabled, Disable Database
Vault before upgrade (Vault installed by default on).

Deinstallation Tool integrated with Installation Media


October 21, 2015

16

The New Version Life is Good!


$ sqlplus ***/***
SQL*Plus: Release 11.1.0.6.0 - Production on Tue Oct 30 11:21:04 2007
Copyright (c) 1982, 2007, Oracle. All rights reserved.

October 21, 2015

17

12.1.0.2 In-Memory Column Store

12.1.0.2

October 21, 2015

18

MEMORY_TARGET & Automatic Memory Management

October 21, 2015

19

Automatic Memory Management (AMM) MEMORY_TARGET in 11g


First there was some Automatic Memory Mgmt - 9i

SGA_MAX_SIZE introduced in 9i Dynamic Memory


No more Buffers DB_CACHE_SIZE
Granule sizes introduced - _ksm_granule_size

Then came SGA_TARGET 10g

Oracle Applications recommends setting this for SGA


Set minimums for key values (Data Cache / Shared Pool)

Now there is MEMORY_TARGET 11g

SGA + PGA all in one setting; Still set minimums

October 21, 2015

20

SGA, PGA, MEMORY_TARGET,


and Database Smart Flash Cache
(cache multiple devices w/o volume manager)

Databas
e Smart
Flash
Cache

October 21, 2015

Database Smart Flash Cache (Solaris/Oracle Linux) L2 cache set 2-10x SGA:
DB_FLASH_CACHE_FILE = /dev/sda, /dev/sdb, /dev/sdc
DB_FLASH_CACHE_SIZE = 32G, 32G, 64G

21

Automatically sized SGA Components that use SGA_TARGET


Component
Fixed SGA
Shared Pool
Large Pool
Java Pool
Buffer Cache
Streams Pool

October 21, 2015

Initialization Parameter
None
SHARED_POOL_SIZE
LARGE_POOL_SIZE
JAVA_POOL_SIZE
DB_CACHE_SIZE
STREAMS_POOL_SIZE

22

Manually Sized SGA (use SGA_TARGET)


PGA_AGGREGATE_LIMIT (New 12c)
Component
Log buffer
Keep Pool
Recycle Pool
Block caches

Initialization Parameter
LOG_BUFFER (pfile only since 10g)
DB_KEEP_CACHE_SIZE
DB_RECYCLE_CACHE_SIZE
DB_nK_CACHE_SIZE

Program Global Area (now in MEMORY_TARGET):


Aggregate PGA
PGA_AGGREGATE_TARGET (11g)
New PGA Limit
PGA_AGGREGATE_LIMIT (12c)
October 21, 2015

23

Moving from SGA_TARGET to:


MEMORY_TARGET (set minimums)
ALTER SYSTEM SET SGA_TARGET=200M;
ALTER SYSTEM SET PGA_AGGREGATE_TARGET=100M;
ALTER SYSTEM SET PGA_AGGREGATE_LIMIT=140M;
SQL> sho parameter target
NAME
TYPE
VALUE
------------------------------------------------ -----------------------memory_max_target
big integer 360M
memory_target
big integer 360M
pga_aggregate_target
big integer 100M
sga_target
big integer 200M
October 21, 2015

24

IM - Initialization Parameters
The Database In-Memory (IM) is not enabled if:
INMEMORY_SIZE is set to zero!
Add space to the SGA_TARGET to accommodate the IM: ALTER
SYSTEM SET SGA_TARGET=200G scope=both (SGA_TARGET
must be large enough for new IM)
ALTER SYSTEM SET INMEMORY_SIZE=100G scope=both
The IM Column Store (IM) creates an area in the SGA called InMemory Area. This is an added memory area in addition to the
buffer cache and other SGA areas.
October 21, 2015

25

Tuning Tools FYI Only DBMS_XPLAN


Use DBMS_XPLAN to query the execution plan

Automatically queries the last plan in PLAN_TABLE


uses a TABLE() function with another pipelined function
Operation text truncation might be a problem
Will give additional information after plan

Highlight filter vs join conditions, if plan table is current


Displays warning message of old version plan table is being used

In 11g, a procedure for SQL Plan Baselines (well cover these later).
DBMS_XPLAN.DISPLAY_SQL_PLAN_BASELINE (
sql_handle IN VARCHAR2 := NULL,
plan_name IN VARCHAR2 := NULL,
format
IN VARCHAR2 := 'TYPICAL') <BASIC/ALL>
RETURN dbms_xplan_type_table;
October 21, 2015

26

Tuning Tools FYI Only DBMS_XPLAN


DBMS_XPLAN Example:
Select *
from table (dbms_xplan.display);
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------| Id

| Operation

Name

| Rows

| Bytes | Cost

| Pstart| Pstop |

-------------------------------------------------------------------------------------|

0 | UPDATE STATEMENT

328 |

2296 |

2 |

1 |

| JOURNAL_LINE

2 |

1 |

4 |

3 |

328 |

2296 |

2 |

1 |

4 |

UPDATE

PARTITION RANGE ALL|


TABLE ACCESS FULL | JOURNAL_LINE

-------------------------------------------------------------------------------------Note: cpu costing is off, 'PLAN_TABLE' is old version


11 rows selected

27

Tuning Tools FYI Only DBMS_XPLAN


select *
from table (dbms_xplan.display);
PLAN_TABLE_OUTPUT
-------------------------------------------------------------------------------Plan hash value: 1363101372

-----------------------------------------------------------------------------| Id

| Operation

| Name

| Rows

| Bytes | Cost (%CPU)| Time

-----------------------------------------------------------------------------|

0 | SELECT STATEMENT

1 |

14 |

728 |

(0)| 00:00:01 |

TABLE ACCESS FULL| EMP_RICH |

14 |

728 |

(0)| 00:00:01 |

-----------------------------------------------------------------------------Note
-----

PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------

dynamic sampling used for this statement (level=2)

28

The Virtual Column FYI

October 21, 2015

29

The Virtual Column


The value of the virtual column is a derived expression.

Can be derived from columns of the same table or from constants


Can include SQL or user-defined PL/SQL functions

Virtual column DATA is NOT PHYSICALLY STORED.


You CAN NOT explicitly write to a virtual column
You CAN create a PHYSICAL index (result is function-based index) or
partition on a virtual column <unlike a computed column in SQL Server or
other databases>
If you UPDATE columns of a virtual column and it has an index, then it will
be computed on the UPDATE vs. on the SELECT (very important from a
tuning standpoint).
Index Organized and External Tables can NOT have virtual columns.
October 21, 2015

30

The Virtual Column


create table emp_rich
(empno number(4),
sal number(7,2),
yearly_sal generated always as (sal*12),
deptno number(2));
Table created.
insert into emp_rich(empno, sal, deptno)
select empno, sal, deptno from scott.emp;
14 rows created.

The Virtual Column


select * from emp_rich;

EMPNO
SAL YEARLY_SAL DEPTNO
------------ ----------- ------------------- ---------------7369
800
9600
20
7499
1600
19200
30
7521
1250
15000
30
7566
2975
35700
20
7654
1250
15000
30
7698
2850
34200
30
...
October 21, 2015

32

Invisible Columns

October 21, 2015

33

Invisible Columns
The new 12c feature allows you to hide columns
If a user or developer selects ALL columns (or does a DESC) from a table (i.e.
select *) the invisible columns will NOT be displayed.
If a user specifically selects the invisible column (i.e. select salary,) the
column WILL be displayed in the output (you have to know its there).
You can set column(s) to be visible/invisible with an alter table :
SQL> ALTER TABLE EMPLOYEE MODIFY (SSN INVISIBLE);
Table altered.

October 21, 2015

34

Invisible Columns Example Simple EMP SELECT


SELECT *
FROM EMP
WHERE SAL > ANY
(SELECT SAL
FROM EMP

WHERE DEPTNO=30)
AND DEPTNO=10
ORDER BY SAL DESC;
EMPNO ENAME

JOB

MGR HIREDATE

DEPTNO

SAL

COMM

---------- ---------- --------- ----- --------- ------- ---------- -----

October 21, 2015

7839 KING

PRESIDENT

17-NOV-81

10

5000

7782 CLARK

MANAGER

7839 09-JUN-81

10

2450

7934 MILLER

CLERK

7782 23-JAN-82

10

1300

Both SAL & COMM columns displayed above!

35

Invisible Columns Example sal/comm to invisible


alter table emp modify (sal invisible, comm invisible);
Table altered.
SELECT *
FROM EMP
WHERE SAL > ANY
(SELECT SAL
FROM EMP
WHERE DEPTNO=30)
AND DEPTNO=10
ORDER BY SAL DESC;
EMPNO ENAME

JOB

MGR HIREDATE

DEPTNO

---------- ---------- --------- ----- --------- -------

October 21, 2015

7839 KING

PRESIDENT

17-NOV-81

10

7782 CLARK

MANAGER

7839 09-JUN-81

10

7934 MILLER

CLERK

7782 23-JAN-82

10

No SAL or COMM columns displayed above!

36

Invisible Columns Example sal invisible but selected


SELECT SAL, JOB, ENAME,DEPTNO
FROM EMP
WHERE SAL > ANY
(SELECT SAL
FROM EMP
WHERE DEPTNO=30)
AND DEPTNO=10
ORDER BY SAL DESC;

SAL JOB

ENAME

DEPTNO

---------- --------- ---------- -------

October 21, 2015

5000 PRESIDENT KING

10

2450 MANAGER

CLARK

10

1300 CLERK

MILLER

10

SAL column IS displayed since I specifically SELECTED it.

37

Invisible Columns Example sal/comm to visible


To turn it back to being visible):
ALTER TABLE EMP MODIFY (SAL VISIBLE, COMM VISIBLE);
Table Altered.

Note: This is not for heavy security; there are other ways to achieve that:
You can use column level security using Oracle's VPD (Virtual Private Database) to
create a policy function and apply the policy function to our table, so that it does NOT
display certain rows for a given deptno, BUT ONLY when the salary and/or COMM
columns are selected. So all rows displayed when I DON'T choose SAL and/or
COMM and all rows EXCEPT deptno 10 when I DO choose the SAL and/or COMM
columns.

You could also use TDE (Transparent Data Encryption) to encrypt the data for a given
column. This is part of Oracle's Database Advanced Security Options and has certain
restrictions.
October 21, 2015

38

The Invisible Index

(Briefly See 12c Best Tuning Features for more)

October 21, 2015

39

The Invisible Index


Set an index to VISIBLE or INVISIBLE

ALTER INDEX idx1 INVISIBLE;


ALTER INDEX idx1 VISIBLE;
CREATE INDEX... INVISIBLE;

Great to turn off indexes for a while when you think theyre not
being used, but BEFORE you drop them.
Can NOT use INDEX hint (to override invisibility) anymore, but
CAN use NO_INDEX (to turn off visible indexes).
The index IS MAINTAINED during DML
Great for testing!
More in the 12c Tuning Session my next session!
October 21, 2015

40

The Invisible Index


create index deptno_invisible_idx on dept_rich(deptno) invisible;
Index created.

select count(*) from dept_rich where deptno = 30; (doesnt see the index)
COUNT(*)
-------------512

Execution Plan
---------------------------------------------------------Plan hash value: 3024595593

-------------------------------------------------------------------------------| Id

| Operation

| Name

| Rows

| Bytes | Cost (%CPU)| Time

--------------------------------------------------------------------------------

October 21, 2015

0 | SELECT STATEMENT

1 |

2 |

1 |

1 |

2 |

|*

2 |

SORT AGGREGATE

TABLE ACCESS FULL| DEPT_RICH |

512 |

(0)| 00:00:01 |
|

1024 |

|
(0)| 0:00:01 |

--------------------------------------------------------------------------------

41

The Invisible Index (set visible)


alter index dept_rich_inv_idx visible;
Index altered.

select count(*) from dept_rich where deptno = 30;


(it does see the index)
COUNT(*)
-------------512
Execution Plan
---------------------------------------------------------Plan hash value: 3699452051
--------------------------------------------------------------------------------------| Id | Operation

| Name

| Rows | Bytes | Cost (%CPU)| Time

--------------------------------------------------------------------------------------| 0 | SELECT STATEMENT |

1|

2|

| 1 | SORT AGGREGATE |

1|

2|

|* 2 |

October 21, 2015

1 (0)| 00:00:01 |
|

INDEX RANGE SCAN| DEPT_RICH_INV_IDX |

512 | 1024 |1 (0)| 00:00:01 |

---------------------------------------------------------------------------------------

42

Multiple Types of Indexes on the Same Column


(Using the Invisible Index even more)
(Briefly See 12c Best Tuning Features for more)

October 21, 2015

43

Multiple Types of Indexes on the Same Column(s)


Create MORE than one index on a column
Set only ONE index to VISIBLE
Great to use different types of indexes for batch, query, or data
warehousing at different times.
Some restrictions applyfor a give column(s)

You can not create a B-tree AND B-tree cluster index


You can not create a B-tree and an index-organized table (IOT)

All indexes ARE MAINTAINED during DML

DML could be slow if TOO MANY indexes are created

Great for variable workloads!


OctoberMore
21, 2015 in the 12c Tuning Session my next session!

44

Multiple Types of Indexes on the Same Column(s)


create index dept_normal on dept(deptno);
create index dept_normal on dept(deptno)

*
ERROR at line 1:
ORA-01408: such column list already indexed

Make FIRST Index Invisible & can now create SECOND index:
alter index dept_unique1 invisible;
Index altered.

create index dept_normal on dept(deptno);


October 21, 2015

Index created.

45

Add Multiple Types of Indexes on the Same Column(s)


Check the Indexes Views FOUR Indexes on the same column:
select a.table_name, a.index_name,

b.column_name, a.uniqueness, a.visibility


from

user_indexes a, user_ind_columns b

where

a.index_name = b.index_name

and

a.table_name = DEPT;

TABLE_NAME INDEX_NAME

COLUMN_NAME

UNIQUENESS

VISIBILITY

---------- --------------- ------------ ------------ ----------

DEPT

DEPT_UNIQUE1

DEPTNO

UNIQUE

INVISIBLE

DEPT

DEPT_REVERSE

DEPTNO

NONUNIQUE

INVISIBLE

DEPT

DEPT_NORMAL

DEPTNO

NONUNIQUE

INVISIBLE

DEPT

DEPT_BITMAP

DEPTNO

NONUNIQUE

VISIBLE

(Index types: NORMAL, NORMAL/REV, UNIQUE, BITMAP)

October 21, 2015

46

Fetch First x Rows Only

October 21, 2015

47

Fetch First or Next 10 rows


Retrieve first rows without scanning everything
Faster query to retrieve a certain number of rows
Skip some rows (offset) to get to the middle of table for sample.
FETCH FIRST x ROWS ONLY clause
or
OFFSET x ROWS FETCH FIRST x ROWS ONLY

October 21, 2015

48

Fetch FIRST x ROWS Only


select count(cust_id)

from customers2
group by cust_id
fetch first 10 rows only;

Elapsed: 00:00:00.95
------------------------------------------------------------------------------------

| Id | Operation
Bytes | Cost |%CPU|

|
Time

Name
|

| Rows

COUNT(CUST_ID)

-----------------PLAN_TABLE_OUTPUT--------------------------------------------------

--------------

0 | SELECT STATEMENT
|
1300K|
30 |(3) | 00:00:01|

51224|

1 | VIEW
|
1300K|
39 |(3) | 00:00:01|

51224|

2 |
650K|

WINDOW NOSORT STOPKEY|


39 |(3) | 00:00:01|

51224|

3 |
650K|

HASH GROUP BY
|
30 |(3) | 00:00:01|

51224|

3 |
650K|

INDEX FAST FULL SCAN|CUSTOMER2_IDX1|51224|


30 |(0) | 00:00:01|

15
27

10 rows selected.

October 21, 2015

------------------------------------------------------------------------------------49

Offset x Rows
Fetch FIRST x ROWS Only
select count(cust_id)

from customers2
group by cust_id
offset 10000 rows fetch first
10 rows only;
COUNT(CUST_ID)
--------------

Elapsed: 00:00:00.95

-----------------------------------------------------------------------------------| Id | Operation
Time
|

10 rows selected.

Name

| Rows

| Bytes | Cost

|%CPU|

-----------------PLAN_TABLE_OUTPUT-------------------------------------------------|

0 | SELECT STATEMENT
00:00:01|

51224|

1300K|

30 |(3) |

1 | VIEW
00:00:01|

51224|

1300K|

39 |(3) |

2 |
WINDOW NOSORT STOPKEY|
00:00:01|

51224|

650K|

39 |(3) |

3 |
HASH GROUP BY
00:00:01|

51224|

650K|

30 |(3) |

3 |
INDEX FAST FULL SCAN|CUSTOMER2_IDX1|51224|
00:00:01|

650K|

30 |(0) |

7700238

1409320

------------------------------------------------------------------------------------October 21, 2015

50

Nice DBA Tools

Change Table Compression at Import Time


& Data Pump Export View as a Table
(Also: No redo logging option of table load/Index creation)

October 21, 2015

51

Change Table Compression at Import


Use impdp command line option (or use DBMS_DATAPUMP)
Use the TABLE_COMPRESSION_CLAUSE:
TABLE_COMPRESSION_CLAUSE=NONE
TABLE_COMRPESSION_CLAUSE=NOCOMPRESS

TABLE_COMPRESSION_CLAUSE=COMPRESS BASIC
TABLE_COMPRESSION_CLAUSE=COMPRESS ROW STORE COMPRESS ADVANCED

(used for OLTP)

Warehouse compression (low is faster load):


TABLE_COMPRESSION_CLAUSE=COMPRESS COLUMN STORE COMPRESS FOR QUERY LOW

TABLE_COMPRESSION_CLAUSE=COMPRESS COLUMN STORE COMPRESS FOR QUERY HIGH

Archive compression (low is faster load):


TABLE_COMPRESSION_CLAUSE=COMPRESS COLUMN STORE COMPRESS FOR ARCHIVE LOW
TABLE_COMPRESSION_CLAUSE=COMPRESS COLUMN STORE COMPRESS FOR ARCHIVE HIGH

impdp hr TABLES=hr.employees DIRECTORY-dpump_dir1 DUMPFILE=hr.dmp TRANSFORM=TABLE_COMPRESSION_CLAUSE=NOCOMPRESS

This is especially helpful for Exadata migrations where more compression options (HCC) are available.
October 21, 2015

52

Change Table Compression at Import


A Basic Example changing a table to COMPRESS:
$ impdp scott2/tiger TABLES=dept2
TRANSFORM=TABLE_COMPRESSION_CLAUSE:compress:table
Master table "SCOTT2"."SYS_IMPORT_TABLE_01" successfully loaded/unloaded
Starting "SCOTT2"."SYS_IMPORT_TABLE_01": scott2/******** TABLES=dept2

TRANSFORM=TABLE_COMPRESSION_CLAUSE:compress:table

Processing object type TABLE_EXPORT/TABLE/TABLE


Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
. . imported "SCOTT2"."DEPT2"

5.937 KB

4 rows

Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS


October 21, 2015

Job "SCOTT2"."SYS_IMPORT_TABLE_01" successfully completed at Sat Mar 2 03:59:51 2013


elapsed 0 00:00:12
53

Create Views as Tables Example


A Basic Example creating (export) views as tables (import):
$ impdp scott2/tiger VIEWS_AS_TABLES
VIEWS_AS_TABLES=schema.view_name:table,

Export a view as a table and then import it:


create view

emp_dept as

(select a.empno, a.ename, b.deptno, b.dname, b.loc


from emp a, dept b where a.deptno=b.deptno);
View created.

$ expdp scott2/tiger VIEWS_AS_TABLES=emp_dept


Processing object type TABLE_EXPORT/VIEWS_AS_TABLES/TABLE
October 21, 2015

. . exported "SCOTT2"."EMP_DEPT"
rows

7.140 KB

14
54

Create Views as Tables Example


SQL> rename emp_dept to emp_dept_view;
$ impdp scott2/tiger VIEWS_AS_TABLES=emp_dept
Processing object type TABLE_EXPORT/VIEWS_AS_TABLES/TABLE_DATA
. . imported "SCOTT2"."EMP_DEPT"
rows

7.140 KB

14

select segment_name, segment_type


from

dba_segments

where

segment_name = 'EMP_DEPT';

SEGMENT_NAME

SEGMENT_TYPE

-------------------- -----------------EMP_DEPT
October 21, 2015

TABLE
55

Pluggable Databases

(Download 12c New Tuning Features for more examples!)

Thanks: Penny Avril & Byrn Liewellyn

October 21, 2015

ORA-65052: statement involves operations with different container scope


ORA-65040: operation not allowed from within a pluggable database
ORA-65017: seed pluggable database may not be dropped or altered

56

Pluggable Databases are Coming!

October 21, 2015

57

Pluggable Databases
CDB = Container Database (has Root DB & also has a seed PDB)
PDB = Pluggable Database (plugged into a CDB)
Non-CDB = Original type of Database (neither a CDB or PDB)
Why?: Cant consolidate 100s of database on one machine too many
resources required when you add the SGAs up! Enter PDBs.

Share: Big Data Sources, Acquisitions, Partners, Shared Research, Governments

October 21, 2015

Quickly create a new database (PDB) or copy existing one (PDB)


Move existing PDBs to new platform or location or clone it (snapshot)
Patch/Upgrade PDB by plugging it into a CDB at a later version
Physical machine runs more PDBs old way: Easier to manage/tune
Backup entire CDB + any number of PDBs
New syntax for commands: PLUGGABLE DATABASE

58

Pluggable Databases

October 21, 2015

59

Is the database a CDB or non-CDB?


SQL> SELECT NAME, CREATED, CDB, CON_ID
2 FROM V$DATABASE;
NAME
CREATED
CDB
CON_ID
---------- --------- --- ---------CDB1
19-FEB-12 YES
0

October 21, 2015

60

Pluggable Databases
In a CDB: Only one CDB$ROOT (Root), only one PDB$SEED (Seed), plus any PDBs (up to 252
more 253 including the seed) that you create or plug in.

CDB Root has schemas, schema objects, data dictionary information about PDBs
Seed database Cant add any objects only to create new PDBs (clone it to create others)
PDB appears to users/applications as if it was a non-CDB. Accessing a PDB is like accessing a
non-CDB
PDBs are how you split applications physically

October 21, 2015

61

Containers 0 - 254
Entire CDB => Container ID = 0
Root (CDB$ROOT) => Container ID = 1
Seed (PDB$SEED) => Container ID = 2
PDBs => Container ID = 3 to 254
(While in PDB1):

(Connect to ROOT):

SQL> SHO CON_ID CON_NAME

SQL> connect / as sysdba


SQL> SHO CON_ID CON_NAME

CON_ID

CON_ID

------------------------------

------------------------------

CON_NAME

CON_NAME

------------------------------

------------------------------

PDB1

CDB$ROOT

(integer overflow!)
62

CDB or PDB created


Background Processes /SGA (shared by root & all PDBs)
Character Set shared by root & all PDBs
Redo shared by root and all PDBs
Undo shared by root and all PDBs
Time Zones can be set for each PDB
Initialization parameters some can be set by PDB
Temporary Tablespace each PDB (future may share)
Separate SYSTEM & SYSAUX for root & each PDB
Data files separate for root & each PDB (same block size)
October 21, 2015

63

Query the PDBs


select name, open_mode, open_time
from v$pdbs;
NAME

OPEN_MODE

OPEN_TIME

--------------- ---------- -------------------------PDB$SEED

READ ONLY

PDB1

READ WRITE 23-FEB-13 05.29.25.846 AM

PDB_SS

READ WRITE 23-FEB-13 05.29.37.587 AM

October 21, 2015

23-FEB-13 05.29.19.861 AM

64

Pluggable Databases
PDB is backward compatible with pre-12c database.
Common users like SYS, SYSTEM connect to the CDB and also
across all PDBS in which it has privileges (you can create your own
common users as well). Common users create/plug/unplug PDBs.
Privileged common users can even switch CDBs

October 21, 2015

Local users are only in a SINGLE PDB (dwadm, erpadm etc.)


Listener, Service Name, ..etc. needed
One CDB has same software version, Active Data Guard, RMAN
Backups, Initialization parameters related to database level (character
set for instance)
Plug or unplug a PDB into a CDB. Plug it in to associate it with the
CDB, consisting of the XML file describing the PDB and its files
65
(database files and wallet file)

From the Oracle docs create DB


CDB must have enable pluggable database
CREATE DATABASE newcdb
USER SYS IDENTIFIED BY sys_password USER SYSTEM IDENTIFIED BY system_password
LOGFILE GROUP 1 ('/u01/logs/my/redo01a.log','/u02/logs/my/redo01b.log') SIZE 100M BLOCKSIZE 512,
GROUP 2 ('/u01/logs/my/redo02a.log','/u02/logs/my/redo02b.log') SIZE 100M BLOCKSIZE 512,
GROUP 3 ('/u01/logs/my/redo03a.log','/u02/logs/my/redo03b.log') SIZE 100M BLOCKSIZE 512 MAXLOGHISTORY 1 MAXLOGFILES 16 MAXLOGMEMBERS 3
MAXDATAFILES 1024 CHARACTER SET AL32UTF8 NATIONAL CHARACTER SET AL16UTF16
EXTENT MANAGEMENT LOCAL
DATAFILE '/u01/app/oracle/oradata/newcdb/system01.dbf' SIZE 700M REUSE AUTOEXTEND ON NEXT 10240K MAXSIZE UNLIMITED
SYSAUX DATAFILE '/u01/app/oracle/oradata/newcdb/sysaux01.dbf' SIZE 550M REUSE AUTOEXTEND ON NEXT 10240K MAXSIZE UNLIMITED
DEFAULT TABLESPACE deftbs DATAFILE '/u01/app/oracle/oradata/newcdb/deftbs01.dbf' SIZE 500M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED
DEFAULT TEMPORARY TABLESPACE tempts1 TEMPFILE '/u01/app/oracle/oradata/newcdb/temp01.dbf' SIZE 20M REUSE AUTOEXTEND ON NEXT 640K
MAXSIZE UNLIMITED
UNDO TABLESPACE undotbs1 DATAFILE '/u01/app/oracle/oradata/newcdb/undotbs01.dbf' SIZE 200M REUSE AUTOEXTEND ON NEXT 5120K MAXSIZE
UNLIMITED

ENABLE PLUGGABLE DATABASE


SEED FILE_NAME_CONVERT = ('/u01/app/oracle/oradata/newcdb/', '/u01/app/oracle/oradata/pdbseed/')
SYSTEM DATAFILES SIZE 125M AUTOEXTEND ON NEXT 10M MAXSIZE UNLIMITED
SYSAUX DATAFILES SIZE 100M

October 21, 2015

USER_DATA TABLESPACE usertbs DATAFILE '/u01/app/oracle/oradata/pdbseed/usertbs01.dbf' SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;66

Creating a PDB: Many ways to do it


Create a PDB by copying the seed PDB
Create a PDB by cloning another PDB
Create a PDB by using the XML metadata files and other files
and plugging them into a CDB
Create a PDB using a non-CDB (multiple ways)

Use DBMS_PDB to create an unplugged PDB


Create an empty PDB and use data pump to move data
Using GoldenGate replication to create

October 21, 2015

67

Create a PDB fyi only(Parameters to possibly set)


PATH_PREFIX = '/disk1/oracle/dbs/dwpdb/'

This PATH_PREFIX clause restricts the location of files and directory object paths
associated with a PDB to the /disk1/oracle/dbs/dwpdb directory.
FILE_NAME_CONVERT = ('/oracle/dbs/', '/oracle/dwpdb/')
This FILE_NAME_CONVERT clause generates file names for the new PDB in the
/oracle/dwpdb directory using file names in the /oracle/dbs directory. This is when
you want to move file location upon creation.
SOURCE_FILE_NAME_CONVERT = ('/disk1/oracle/pdb1/',
'/disk2/oracle/pdb1/'). This SOURCE_FILE_NAME_CONVERT clause uses the
files in the /disk2/oracle/pdb1 directory instead of the /disk1/oracle/pdb1 directory. In
this case, the XML file describing a PDB specifies the /disk1/oracle/pdb1 directory,
but the PDB should use the files in the /disk2/oracle/pdb1 directory. NONE if
location is correct.
October 21, 2015

68

Create a PDB - fyi only


CREATE PLUGGABLE DATABASE dwpdb ADMIN USER dwadm IDENTIFIED
BY password;
CREATE PLUGGABLE DATABASE dwpdb ADMIN USER dwadm IDENTIFIED
BY password ROLES=(SELECT_CATALOG_ROLE,
GATHER_SYSTEM_STATISTICS);
(PDB_DBA role is also granted in addition to the above specifically granted roles.)
CREATE PLUGGABLE DATABASE dwpdb ADMIN USER dwadm IDENTIFIED
BY password STORAGE (MAXSIZE 10G MAX_SHARED_TEMP_SIZE 100M)
DEFAULT TABLESPACE dw DATAFILE '/disk1/oracle/dbs/dwpdb/dw1.dbf' SIZE
2G AUTOEXTEND ON PATH_PREFIX = '/disk1/oracle/dbs/dwpdb/'
FILE_NAME_CONVERT = ('/disk1/oracle/dbs/pdbseed/',
'/disk1/oracle/dbs/dwpdb/');

October 21, 2015

69

Cloning a PDB
CREATE PLUGGABLE DATABASE pdb2 FROM pdb1
PATH_PREFIX = '/disk2/oracle/pdb2'
FILE_NAME_CONVERT = ('/disk1/oracle/pdb1/',
'/disk2/oracle/pdb2/');
CREATE PLUGGABLE DATABASE pdb2 FROM pdb1
FILE_NAME_CONVERT = ('/disk1/oracle/pdb1/',
'/disk2/oracle/pdb2/') STORAGE (MAXSIZE 2G
MAX_SHARED_TEMP_SIZE 100M);
CREATE PLUGGABLE DATABASE pdb2 FROM
pdb1@pdb1_link;
October 21, 2015

70

Cloning a PDB
CREATE PLUGGABLE DATABASE pdb2 FROM pdb1;
*

ERROR at Line 1:
ORA-65016: FILE_NAME_CONVERT must be specified

CREATE PLUGGABLE DATABASE pdb2 FROM pdb1


FILE_NAME_CONVERT = ('/u01/app/oracle/oradata/cdb1/pdb1',
'/u01/app/oracle/oradata/cdb1/pdb2);

October 21, 2015

Note: pdb1 must be OPEN and READ ONLY mode or ORA-65001

71

Create PDB from non-CDB (3 ways) (fyi only)


Use Oracle Data Pump with or without transportable
tablespaces (11.2.0.3 full transportable export).
Create an empty PDB and then import into it.
Use Oracle GoldenGate replication replicate from
non-CDB to PDB & fail over when replication catches
up with non-CDB.
Execute DBMS_PDB.DESCRIBE on a non-CDB in
Oracle Database 12c Release 1 (12.1) creates the
.XML Metadata file. You can then use this with the
database files to create a PDB (see next slide).
October 21, 2015

72

Use DBMS_PDB to create

PDB from non-CDB (fyi only)

Ensure non-CDB is in a transactionally-consistent state and place it in read-only mode.

Generate an XML file (ncdb.xml) in /disk1/oracle directory:


BEGIN
DBMS_PDB.DESCRIBE(

pdb_descr_file => '/disk1/oracle/ncdb.xml');


END;
/

Shutdown the non-CDB.


Plug in the non-CDB, Access the PDB.
Run the noncdb_to_pdb.sql script:

@$ORACLE_HOME/rdbms/admin/noncdb_to_pdb.sql

Open the new PDB in read/write mode & Back up the PDB.

October 21, 2015

73

Plug in an Unplugged PDB


CREATE PLUGGABLE DATABASE dwpdb USING
'/disk1/usr/dwpdb.xml' NOCOPY TEMPFILE REUSE;
CREATE PLUGGABLE DATABASE dwpdb USING
'/disk1/usr/dwpdb.xml'
SOURCE_FILE_NAME_CONVERT =
('/disk1/oracle/dw/', '/disk2/oracle/dw/') NOCOPY
STORAGE (MAXSIZE 4G
MAX_SHARED_TEMP_SIZE 100M) TEMPFILE
REUSE;
You can unplug/plug across database version
boundaries!
October 21, 2015

74

Unplugging & Dropping PDBs


ALTER PLUGGABLE DATABASE dwpdb UNPLUG INTO
'/oracle/data/dwpdb.xml';
DROP PLUGGABLE DATABASE dwpdb KEEP DATAFILES;
DROP PLUGGABLE DATABASE dwpdb INCLUDING
DATAFILES;

October 21, 2015

75

Connecting to CDB/PDB Using sqlplus


To connect to the root must be a common user & must
have create session privilege in the root.
To connect to a PBD, must either be common user with
local create session or local PDB user with create
session.
Use SQLPLUS /nolog and then CONNECT
Connect / as sysdba (to root, just as a non-CDB)

October 21, 2015

76

Pluggable Databases

October 21, 2015

_common_user_prefix=c##
_common_user_prefix=

77

Moving between CDB/PDBs Switch Containers


SQL> ALTER SESSION SET CONTAINER=PDB1;
Session altered.

SQL> alter session set container=CDB1;


ERROR:

ORA-65011: Pluggable database does not exist

ALTER SESSION SET CONTAINER=CDB$ROOT;


Session altered.

ALTER SESSION SET CONTAINER=PDB$SEED;


Session altered.

ALTER SESSION SET CONTAINER=pdb_ss; (not case sensitive)


Session altered.
October 21, 2015

78

DBA_CONTAINER_DATA
SQL> desc dba_container_data
Name

Null?

Type

----------------------------------------- -------- --------------USERNAME

VARCHAR2(128)

DEFAULT_ATTR

CHAR(1)

OWNER

VARCHAR2(128)

OBJECT_NAME

VARCHAR2(128)

ALL_CONTAINERS

VARCHAR2(1)

CONTAINER_NAME

VARCHAR2(128)

SELECT * FROM DBA_CONTAINER_DATA;

USERNAME

D OWNER

OBJECT_NAM A CONTAINER_

---------- - ---------- ---------- - ----------

October 21, 2015

SYSTEM

DBSNMP

SYS

SYSBACKUP

79

Open/Close PDBs
SQL> ALTER PLUGGABLE DATABASE CLOSE IMMEDIATE;
Pluggable database altered.
SQL> ALTER PLUGGABLE DATABASE OPEN READ WRITE;
Pluggable database altered.
SQL> ALTER PLUGGABLE DATABASE CLOSE; (shutdown)
Pluggable database altered.
Alter pluggable database open upgrade; (to migrate)
Pluggable database altered.
October 21, 2015

80

Open/Close PDBs
ALTER PLUGGABLE DATABASE PDB_SS, PDB1 CLOSE; (not in
CDB)
ALTER PLUGGABLE DATABASE PDB_SS, PDB1 CLOSE
*
ERROR at line 1:
ORA-65040: operation not allowed from within a pluggable database

alter session set container=CDB$ROOT;

Session altered.
alter pluggable database ALL open read only; (from CDB)
Pluggable database altered.
ALTER PLUGGABLE DATABASE PDB_SS, PDB1 CLOSE;
October 21, 2015

Pluggable database altered.


81

Check PDB status


select name, open_mode,
from

open_time

v$pdbs;

NAME

OPEN_MODE

OPEN_TIME

---------- ---------- -------------------------

PDB$SEED

READ ONLY

11-MAR-13 09.29.18.284 PM

PDB1

MOUNTED

27-MAR-13 01.19.02.666 AM

PDB_SS

MOUNTED

27-MAR-13 01.19.02.985 AM

October 21, 2015

82

Open/Close PDBs
ALTER PLUGGABLE DATABASE PDB_SS, PDB1 open;
Pluggable database altered.
select name, open_mode,
from

open_time

v$pdbs;

NAME

OPEN_MODE

OPEN_TIME

---------- ---------- -------------------------

October 21, 2015

PDB$SEED

READ ONLY

11-MAR-13 09.29.18.284 PM

PDB1

READ WRITE 27-MAR-13 01.26.32.905 AM

PDB_SS

READ WRITE 27-MAR-13 01.26.36.559 AM


83

Open/Close PDBs
alter pluggable database all except pdb1 close immediate;
Pluggable database altered.

select name, open_mode,


from
NAME

open_time

v$pdbs;
OPEN_MODE

OPEN_TIME

---------- ---------- ------------------------PDB$SEED

READ ONLY

11-MAR-13 09.29.18.284 PM

PDB1

READ WRITE 27-MAR-13 01.26.32.905 AM

PDB_SS

MOUNTED

27-MAR-13 01.29.47.225 AM

alter pluggable database pdb$seed close immediate;


alter pluggable database pdb$seed close immediate
*

October 21, 2015

ERROR at line 1:
ORA-65017: seed pluggable database may not be dropped or altered

84

Startup PDB
Startup pluggable database pdb1
open;(read/write)
Pluggable Database opened.

(or while in pdb1 just run STARTUP)


Startup pluggable database pdb1 open
read only;
Pluggable Database opened.

Startup pluggable database pdb1 force;


(closes/opens)

Pluggable Database opened.


(or while in pdb1 just run STARTUP FORCE)
October 21, 2015

85

Careful New commands!


SQL> SHUTDOWN PLUGGABLE DATABASE PDB1;

SP2-0717: illegal SHUTDOWN option


SQL> STARTUP
Pluggable Database opened.
SQL> SHUTDOWN (also SHUTDOWN ABORT works)
ORACLE instance shut down.
select name, open_mode,
from
NAME

open_time

v$pdbs;
OPEN_MODE

OPEN_TIME

---------- ---------- ------------------------PDB1


October 21, 2015

MOUNTED

27-MAR-13 01.50.25.345 AM
86

Query CDB before PDB1 startup


SQL> connect / as sysdba
Connected.
select name, open_mode,
from

October 21, 2015

open_time

v$pdbs;

NAME
---------PDB$SEED
PDB1
PDB_SS

OPEN_MODE
---------READ ONLY
MOUNTED
READ WRITE

OPEN_TIME
------------------------11-MAR-13 09.29.18.284 PM
27-MAR-13 02.00.06.536 AM
27-MAR-13 01.41.58.049 AM
87

When you startup the CDB


ORACLE instance started.

select name, open_mode,


from
v$pdbs;

Total System Global Area

NAME

SQL> startup

Fixed Size

Variable Size
Database Buffers
Redo Buffers

626327552 bytes
2276008 bytes

524289368 bytes
92274688 bytes
7487488 bytes

OPEN_MODE

OPEN_TIME

---------- ---------- -----------------------PDB$SEED


READ ONLY
02.04.46.883 AM

Database mounted.

PDB1

MOUNTED

Database opened.

PDB_SS

MOUNTED

October 21, 2015

open_time

27-MAR-13

88

RMAN & other Nice Commands


alter pluggable database all open;
(great command!)

RMAN> alter pluggable database pdb1 close;


RMAN> restore pluggable database pdb1;
RMAN> recover pluggable database pdb1 until
SCN 777070;
RMAN> alter pluggable database pdb1 open resetlogs;
srvctl add service pdb <pdb_name>
October 21, 2015

89

V$ Views
New views start with CDB_ are CDB only
Dictionary/Performance views (V$) show only
PDB when queried from that PDB (isolation)
Query performance views from root & will show
all PDBs
PDBs have container identifier when you look
at root see all of the ids
V$SESSION & V$INSTANCE have a CON_ID
column for containers (& new V$IO_OUTLIER)
October 21, 2015

90

Where is Everything?
SELECT d.con_ID, p.PDB_NAME, d.FILE_ID, d.TABLESPACE_NAME,
d.FILE_NAME
FROM

CDB_PDBS p, CDB_DATA_FILES d

WHERE

p.PDB_ID(+) = d.CON_ID

order

by d.con_id;

CON_ID PDB

FILE_ID TABLESPACE_NAME

FILE_NAME

--------- --------- --------- ---------------- -----------------------------------------------

October 21, 2015

USERS

/u01/app/oracle/oradata/cdb1/users01.dbf

UNDOTBS1

/u01/app/oracle/oradata/cdb1/undotbs01.dbf

SYSAUX

/u01/app/oracle/oradata/cdb1/sysaux01.dbf

SYSTEM

/u01/app/oracle/oradata/cdb1/system01.dbf

2 PDB$SEED

SYSTEM

/u01/app/oracle/oradata/cdb1/pdbseed/system01.dbf

2 PDB$SEED

SYSAUX

/u01/app/oracle/oradata/cdb1/pdbseed/sysaux01.dbf

3 PDB1

SYSTEM

/u01/app/oracle/oradata/cdb1/pdb1/system01.dbf

3 PDB1

SYSAUX

/u01/app/oracle/oradata/cdb1/pdb1/sysaux01.dbf

4 PDB_SS

SYSTEM

/u01/app/oracle/oradata/cdb1/pdb_ss/system01.dbf

4 PDB_SS

10

SYSAUX

/u01/app/oracle/oradata/cdb1/pdb_ss/sysaux01.dbf

4 PDB_SS

11

EXAMPLE

/u01/app/oracle/oradata/cdb1/pdb_ss/example.dbf

11 rows selected.

91

Map tables to PDBs


SELECT p.PDB_ID, p.PDB_NAME, t.OWNER, t.TABLE_NAME
FROM

CDB_PDBS p, CDB_TABLES t

where

p.PDB_ID = t.CON_ID

AND

T.OWNER ='ORDDATA

ORDER

BY t.TABLE_NAME;

PDB_ID PDB_NAME

OWNER

TABLE_NAME

---------- ---------- ---------- -----------------------------2 PDB$SEED

ORDDATA

ORDDCM_ANON_ACTION_TYPES

3 PDB1

ORDDATA

ORDDCM_ANON_ACTION_TYPES

2 PDB$SEED

ORDDATA

ORDDCM_ANON_ATTRS

3 PDB1

ORDDATA

ORDDCM_ANON_ATTRS

3 PDB1

ORDDATA

ORDDCM_ANON_ATTRS_TMP

2 PDB$SEED

ORDDATA

ORDDCM_ANON_ATTRS_TMP

3 PDB1

ORDDATA

ORDDCM_ANON_ATTRS_WRK

2 PDB$SEED

ORDDATA

ORDDCM_ANON_ATTRS_WRK

October 21, 2015

92

Check PDB History


SELECT DB_NAME, CON_ID, PDB_NAME, OPERATION,
OP_TIMESTAMP, CLONED_FROM_PDB_NAME

FROM

CDB_PDB_HISTORY

WHERE

CON_ID > 2

ORDER

BY CON_ID;

Sample output:
DB_NAME

CON_ID PDB_NAME

OPERATION

OP_TIMEST CLONED_FROM_PDB

---------- ------ --------------- ---------------- --------- --------------NEWCDB

3 PDB1

CREATE

01-APR-13 PDB$SEED

NEWCDB

4 PDB_SS

CREATE

01-APR-13 PDB$SEED

NEWCDB

5 PDB2

CLONE

02-APR-13 PDB1

October 21, 2015

93

Sanity check -what do I have


select name, service_id, con_name, con_id
from

v$active_services

order

by 1;

NAME

SERVICE_ID CON_NAME

CON_ID

--------------- ---------- --------------- ----------

SYS$BACKGROUND

1 CDB$ROOT

SYS$USERS

2 CDB$ROOT

cdb1

6 CDB$ROOT

cdb1XDB

5 CDB$ROOT

pdb1

3 PDB1

pdb_ss

3 PDB_SS

6 rows selected.

94

ALTER SYSTEM while in PDB


Effect of flushing shared_pool or buffer cache at different levels
ALTER SYSTEM FLUSH SHARED_POOL
ALTER SYSTEM FLUSH BUFFER_CACHE
ALTER SYSTEM SET USE_STORED_OUTLINES
ALTER SYSTEM SUSPEND/RESUME
ALTER SYSTEM CHECKPOINT
ALTER SYSTEM KILL SESSION
ALTER SYSTEM DISCONNECT SESSION
ALTER SYSTEM SET initialization_parameter
(Great commands to run at the PDB level)

95

Able to modify initialization parameter for a given PDB


SELECT NAME FROM V$PARAMETER
WHERE

ISPDB_MODIFIABLE

AND

NAME LIKE 'optim%;

= 'TRUE'
(without condition can set 147 parameters out of 357)
(There were 341 parameters in 11gR2)

NAME
---------------------------------------optimizer_adaptive_reporting_only
optimizer_capture_sql_plan_baselines
optimizer_dynamic_sampling
optimizer_features_enable
optimizer_index_caching
optimizer_index_cost_adj
optimizer_mode
optimizer_use_invisible_indexes
optimizer_use_pending_statistics
optimizer_use_sql_plan_baselines
10 rows selected.

Key ones modifiable: cursor_sharing, open_cursors, result_cache_mode, sort_area_size


Key ones NOT modifiable: shared_pool_size, db_cache_size, memory_target, pga
October 21, 2015

96

Set PDB Resource Plans


Keep runaway PDBs from affecting other PDBs
Allocate appropriate resource plans (between/within
PDBs)
Set min/max CPU / I/O / Parallelism / (Future:
Memory / Network / I/O on non-Exadata)
alter system set RESOURCE_LIMIT = TRUE_CONTAINER =
ALL (dynamically enable resource limits for all containers)
alter system set RESOURCE_LIMIT = TRUE_CONTAINER =
CURRENT (dynamically enable resource limits for the root)
October 21, 2015

97

Set PDB Resource Plans


If 4 PDBs have 3 shares each, there are 12 shares total and each has 3/12 or 1/4th
of the CPU resources.
If 2 PDBs have 3 shares & 2 PDBs have 1 share, then the ones with 3 shares have
3/8ths of the CPU resources and are 3x more likely to queue parallel queries than
the ones that have 1 share.
CPU utilization_limit and parallel_server_limit percents also can be set.
BEGIN DBMS_RESOURCE_MANAGER.CREATE_CDB_PLAN_DIRECTIVE(
plan => 'newcdb_plan',
pluggable_database => pdb1',
shares => 3,
utilization_limit => 70,
parallel_server_limit => 70);
END;
/
October 21, 2015

98

Resource Plan Queries


SELECT PLAN, STATUS, COMMENTS
FROM
DBA_CDB_RSRC_PLANS
ORDER BY PLAN;
PLAN
------------------------DEFAULT_CDB_PLAN
ORA$INTERNAL_CDB_PLAN

STATUS
-------------------ACTIVE
ACTIVE

COMMENTS
-------------------Default CDB plan
Internal CDB plan

SELECT PLAN, PLUGGABLE_DATABASE, SHARES,


UTILIZATION_LIMIT, PARALLEL_SERVER_LIMIT
FROM DBA_CDB_RSRC_PLAN_DIRECTIVES
ORDER BY PLAN;

October 21, 2015

Pluggable
Utilization Parallel
Plan
Database
Shares
Limit
Limit
-------------------------- ------------------------- ------ ----------- -------DEFAULT_CDB_PLAN
ORA$DEFAULT_PDB_DIRECTIVE
1
100
100
DEFAULT_CDB_PLAN
ORA$AUTOTASK
90
100

99

Resource Plans for CDB/PDB


(Use 12c Cloud Control OEM)

October 21, 2015

100

Get Ready for Pluggable Databases!

October 21, 2015

This guy and his team working hard to make your life easier!

101

In Memory DB with CDB/PDB


IMMEMORY_SIZE
(Shared by all PDBs)

Local
IM alloc

Local
IM alloc

Local
IM alloc

Global CDB INMEMORY_SIZE


There are local settings in each PDB as well
Place objects INMEMORY in each PDB
Starting PDBs & setting PRIORITY very important
October 21, 2015

102

Vbox running 12c Database

October 21, 2015

103

Other Nice Developer Tools / Improvements


DDL_LOCK_TIMEOUT 11g
Enhanced DDL Capabilities 12c
Adaptive Query Optimization 12c
(Briefly See 12c Best Tuning Features for more)

October 21, 2015

104

The DDL Lock Timeout


DDL Statements (Create/Alter/Drop) require exclusive locks and
thus sometimes fail due to bad timing.
The parameter DDL_LOCK_TIMEOUT specifies the amount of
time (in seconds) the DDL statement will wait for the lock before
timing out and failing.
The default value is 0, the max value is 100000 (27.77 hours).
Example:
alter session set DDL_LOCK_TIMEOUT = 30
Session altered.

You can specify a lock timeout in seconds for FINISH_REDEF_TABLE


October 21, 2015

105

Enhanced DDL Online


Many schema level DDL maintenance commands no longer have
blocking locks. Less of an issue for online use while there are
users using the objects. This DDL non-blocking operations
include:

DROP INDEX ONLINE


DROP CONSTRAINT ONLINE
SET UNUSED COLUMN ONLINE
ALTER INDEX VISIBLE
ALTER INDEX INVISIBLE
SET UNUSED COLUMN ONLINE
Can also now move a Data File while Online and is open and being accessed!
October 21, 2015

106

Adaptive Query Optimization


(Thanks Oracle docs.)

October 21, 2015

107

Adaptive Query Optimization


(Briefly See 12c Best Tuning Features for more)

Adaptive query optimization allows optimizer to adjust execution plan at run time when
additional/better information is available.

Adaptive Plans: Different Join Methods (change NL to HASH) or Parallel Distribution


Adaptive Statistics: Dynamic stats, Auto Reoptimization, and SQL Plan Directives

Adaptive Plans does not pick the final plan until execution time based on statistics collection.
Information learned at execution time is used in future executions. Youll see the plan table
output in the note section:
Note
-------------------------- this is an adaptive plan

The 12c Adaptive Optimizer adapts plans based on not just the original tables stats, but also
additional adaptive statistics
There are three types of Adaptive Statistics:
October 21, 2015

Dynamic Statistics (previously dynamic sampling in 10g/11g) or runtime statistics


Automatic Reoptimization or statistics generated after the initial execution
SQL Plan Directives direct optimizer to dynamic statistics & gets accurate cardinality

108

Adaptive Query Optimization: Oracle Docs Great Example

October 21, 2015

109

Adaptive Query Optimization: Oracle Docs Great Example

October 21, 2015

Shows Initial Plan

Shows Final Plan

110

Database Workload Capture and Replay


Used to capture database workload on one system and replay later on a
different system. Useful to compare two different systems.
Could rival LoadRunner in the future (may be more precise!)
Brief Steps:
Capture workload on a database even from 10gR2
Restore the database on a test system to the SCN when capture begins
Perform upgrade and make changes to the test system as needed
Preprocess the captured workload if it is not preprocessed
Configure the test system for replay (I dont do this here)
Replay workload on the restored database (I dont have this in this
presentation, but will show some of the screens to do it)
Great to test upgrade to 11g (Capture 10gR2 then test against 11g)
111

DB Replay Options...
Synchronized Replay

Exact Concurrency, commits & data divergence minimal

Unsynchronized Replay

Not the same concurrency or commits


Data divergence can be large depending on load test
performed

Creates Report Better Reporting in

Data Divergence, Error Divergence, Performance Divergence

NEW in 12c (11gR2 part): Consolidated Database


Replays

Take multiple workloads on different databases and consolidate

into a single replay (either manually with non-CDBs or with


PDBs).
October 21, 2015

112

Database Replay Options...

(Thanks Oracle/Jagan Athreya for this slide!)

October 21, 2015

113

Automatic Diagnostic Repository (ADR)


Oracle includes a Fault Diagnosability Infrastructure to prevent, detect,
diagnose, resolve issues related to bugs, corruption, etc.
When a critical error occurs it is assigned an incident number and all
diagnostic data tagged with this in ADR.
ADR is a file based repository outside of the database
ADR helps detect problems proactively
ADR helps limit the damage of interruptions
ADR helps reduce problem diagnostic time
ADR simplifies Oracle Support / Customer interaction
The ADR also contains Health Reports, Trace Files, Dump Files, SQL Test
Cases and Data Repair Records
October 21, 2015

114

ADR Directory Structure for a


Database Instance
ADR Base
Alert Log:
/u01/app/oracle/diag/rdbms/c
db1/cdb1/trace
ORACLE_HOME:
/u01/app/oracle/product/12.1.
0/dbhome_1

diag
rdbms

<database name>
<SID>

alert
October 21, 2015

cdump

incident

trace

(others)
115

ADR V$ Diagnostic Info 12c No changes (that I saw)

October 21, 2015

116

Security Enhancements
Enhanced security of Audit Data with new AUDIT_ADMIN role

Also SYSBACKUP privilege (dont need SYSDBA for RMAN)


Update strong user authentication using kerberos
Simplified Vault administration

October 21, 2015

117

Oracle Database Security


Built over MANY years...
Oracle Audit Vault
Oracle Database Vault
DB Security Evaluation #19
Transparent Data Encryption
EM Configuration Scanning
Fine Grained Auditing (9i)
Secure application roles
Client Identifier / Identity propagation
Oracle Label Security (2000)
Proxy authentication
Enterprise User Security
Global roles
Virtual Private Database (8i)

October 21, 2015

1977

Database Encryption API


Strong authentication (PKI, Kerberos, RADIUS)
Native Network Encryption (Oracle7)
Database Auditing
Government customer

2007
118

Other 12c Features


Database Instance Smart Flash Cache Support for Multiple Devices (can access/combine) without the overhead of the local volume
manager.

Supports In-Memory Jobs & In-Memory Temporary Tablespaces


Active Data Guard Security has in-memory table of failed login attempts
Heat Map that tracks modifications of rows (block level), table, partition levels
Automate policy-driven data movement and compression using Heat Map

Move partitions while ONLINE with DML happening / Flex ASM to other storage
Improved query performance against OLAP cubes (especially Exadata)
Automatic extended stats for groups of columns accessed together
DBMS_STATS.GATHER_TABLE_STATS run on a partitioned table when CONCURRENT is
set to TRUE will gather stats using multiple jobs concurrently
Online statistics gathered during a bulk load (similar to rebuild index command)
Flashback Data Archive (FDA) can be fully used on HCC tables on Exadata
Enterprise Manager Database Express 12c ships with every database (NICE!)
Spot ADDM triggered by high CPU or I/O into AWR Reports
Mask Data At Source for testing & Oracle Masking templates for E-Business
Oracle Data Redaction (prevents things like SSN from being displayed)
October 21, 2015

119

Other 12c Features


Full Transportable support & Point-in-time recovery for PDBs
TRUNCATE TABLE CASCADE (truncate child tables too)
Data Pump No Logging Option for import

No-echo of Encryption Passwords on expdp/impdp commands


Sql*Loader Express Mode no control file!
In-Database MapReduce (Big Data)
Update strong user authentication using kerberos & Simplified Vault administration

Many Windows enhancements (if you must use Windoze)


Fast Application Notification (FAN) gets improved with Application Continuity which helps recover incomplete requests without
executing more than once.
Real-Time Apply (redo) is now default for Data Guard vs. applying archive logs
SQL Apply Support for Objects, Collections, XML Type, & SecureFiles LOBs
Oracle Spacial is now Oracle Spacial & Graph Enhancements include routing engine enhancements, caching of index metadata,
vector performance, Asian address support (geocoding), raster algebra & analytics, enhance image processing
Many ACFS, Oracle Multimedia, Oracle Text & Oracle XML enhancements
VARCHAR2(32767) not default/4K stored inline/>4K out of line(like a LOB)
October 21, 2015

120

12c Deprecated Features fyi


(could be desupported in future releases)

Oracle Streams, Oracle Database Advanced Replication, & Oracle


Change Data Capture are all deprecated use Oracle GoldenGate.
OEM DB Control is desupported use OEM Express.
IGNORCASE argument of ORAPWD
Single character options with SVRCTL (accepts full-word options now)
*_SCHEDULER_CREDENTIALS
Oracle Net Listener Password is deprecated. Oracle ensures no loss of
security security now enforced via local OS authentication.
V$OBJECT_USAGE is deprecated.
(See documentation for more )
October 21, 2015

121

V$ Views over the years

October 21, 2015

Version
6
7
8.0
8.1
9.0
9.2
10gR1
10gR2

V$ Views
23
72
132
185
227
259
340 (+31%)
396

X$ Tables
? (35)
126
200
271
352
394
543 (+38%)
613

11gR1

484 (+42%)

798 (+46%)

11gR2
12cR1

525 (+33%)
606 (+25%)

945 (+54%)
1062 (+33%)

122

More SPEED Coming Get Ready


This guy does not ever slow down!!

October 21, 2015

123

Benefits Multiply*: Access 1/2000th the data; Its


like getting 8P memory resident in 4T of an X3-8

10 TB of user data
Requires 10 TB of IO

1 TB
with compression

100 GB
with partition pruning

Sub second
On Database
Machine
20 GB
with Storage Indexes

5 GB
with Smart Scans

Data is 10x Smaller, Scans are 2000x faster


October 21, 2015

*Oracle Slide Thanks!

124

The X5-2 is much more than X4-2


100% more Flash Memory (89.6T total)
167% more CPU cores (684 total) for processing
71% more CPU cores (288 Total) dedicated to SQL
processing in storage
100% more DRAM (6T)
New Flash Drives with up to 1.6Tx112 = 179.2T (EF) EF =
Extreme Flash
Can expand V2, X2, X3; Also, 1/8 rack available on X5-2
Other Features include:
Exadata Columnar Flash Cache
October 21, 2015

125

X5-2: Full Rack or or or 1/8


Memory/DRAM

Servers/cores
Servers/disks**
Flash Memory

EF (Extreme Flash)
SAS (High Capacity)
Flash IOPs*
InfiniBand Switches

Data Load Rates


October 21, 2015

Full
4T
8/288
14/168
44.8T
179T
672T
4,144,000
2
20T/hr*

Half
2T
4/144
7/84
22.4T
90T
336T
2,072,000
2
10T/hr*

Quarter Eighth
1T
1T
2/72
2/36
3/36
3/18
9.6T
4.8T
38.4T
19.2T
144T
72T
1,036,000 518K
2
2
5T/hr*
2.5T/hr

* Estimate (Reads of 8K blocks Writes are the same for Flash and around for disk
** 4T High Capacity SAS or 1.6T NVMe PCI Flash Drives; X5-2, X4-2, X3-2 has 1/8 Rack, the X2-2 does not!

126

Oracle FS1 Flash Array


A Single FS1-2 Storage System:
912T of Flash
2.9P of Flash/Disk
4 CPU / 24 cores
64G RAM / 16G NV-DIMM
(base controller)
384G RAM / 16G NV-DIMM
(performance controller)
October 21, 2015

127

Do you really need all the CPUs / RAM?


4000 nodes &
16P raw disk

2 Nodes (X5-2 + BDA5-2):


672T + 864T x 15x compression = 23P
raw disk equivalent
October 21, 2015

128

The In-Memory Column Store (IM)

12.1.0.2

Covered in Detail at 11 AM session in MS 304

October 21, 2015

129

In-Memory (IM) Overview

12.1.0.2

Both OLTP & DWHSE applications are common in most


enterprises. We have a buffer cache for OLTP & all the DML you
might do, while also having the IM cache to improve performance
in data warehousing that stays consistent even when the other
OLTP cache changes (similar to how tables/indexes stay
consistent).
You can now support mixed workloads. This extends even into
multi-tenant databases, RAC, and Exadata as well.
IM is fully compatible with all your current applications and ALL
existing current database features; it requires NO changes at the
application level.
October 21, 2015

130

Oracles new In-Memory Option*


100x faster real time analytics queries
2x faster OLTP & 3-4x faster INSERTS
Oracle demo showed Wikipedia query 1354x faster than NO INDEX
vs. NO INDEX using In-Memory (Drop analytics indexes?)

Easy settings** (flip a switch):


inmemory_size = 2000G
alter table EMP inmemory;

(can also alter for individual partition)

* Announced /not yet available (loaded on startup/first access)


** No documented/undocumented parameter in current version.
October 21, 2015

131

IM Why its a Better Way


Reasons why IM is more better than others:
Access only column data needed
Scan/filter data in compressed format
Using storage indexes to prune using min/max in each IMCU
Additional pruning can be done using metadata dictionary (if dictionary based
compression is used) dictionary contains list of unique columns

Use SIMD to apply filter predicates using vector processing


evaluate multiple values with a single CPU instruction. Billions of
rows scanned vs. millions in buffer cache.
Can be partially populated during startup and later filled with
accessed objects (there are also crash benefits see docs).
October 21, 2015

132

IM Why so fast?
SIMD (Simple Instruction, Multiple Data)

Concept of SIMD

Oracle SIMD From Oracle

Performs the same operation on multiple data points simultaneously - Wikipedia (i.e. Scans
multiple data values in the same CPU instruction (instead of one at a time)).
October 21, 2015

133

Oracles M6-32 SuperCluster Machine*


Fastest Database Machine
Integrated Exadata Storage for 10x database I/O acceleration
Connected to Exadata Storage Expansion Rack
InfiniBand I/O Interconnect
3T Silicon Network for CPU communications
32T Memory for Column Store
Oracle Demo:

341 B rows/sec WOW!!


(accessing 218B row table sub-second)
* Available NOW!
October 21, 2015

134

In-Memory Column Store

12.1.0.2

In- Memory (IM) or the IM Column Store (IM)


You must be on 12.1.0.2 or later.
It is installed with the database (by default) you cant de-select it.
It is NOT enabled by default (set INMEMORY_SIZE)
The IM must be at least 100M
It is divided into 1M (store column data) and 64K (stores object
metadata & storage indexes) pools.
A table is columnized, compressed, & then populates the IM.
Oracle uses populate the IM since loading/inserting implies new
data whereas the IM is existing data
October 21, 2015

135

Whats in the IM?

12.1.0.2

INMEMORY can be specified at the:


Table
Tablespace
Partition
Subpartition
Materialized view level
The dual-format architecture does not double memory and is
expected to cause less than 20% memory overhead. There could
be some performance impact on the IM side when the OLTP side
does a DML if a table is in both.
October 21, 2015

136

In-Memory Column Store


Other Notes on the IM:
No Indexes (dont need them or will be created)
No IOTs (Index Organized Tables)
No cluster tables
No objects smaller than 64K (no waste in 1M pool)
No SYS owned objects stored in SYSTEM/SYSAUX
No LONGS (deprecated) or Out of line LOBS
May be others see the docs for complete list
When you are out of space, you are out! until something is
removed in some way.

October 21, 2015

137

IM - Initialization Parameters
The Database In-Memory is not enabled if: INMEMORY_SIZE is
set to zero!
Add space to the SGA_TARGET to accommodate the IM: ALTER
SYSTEM SET SGA_TARGET=200G scope=both (SGA_TARGET
must be large enough for new IM)
ALTER SYSTEM SET INMEMORY_SIZE=100G scope=both
The IM Column Store (IM) creates an area in the SGA called InMemory Area (IM Column Store). This is an added memory area
in addition to the buffer cache and other SGA areas.

October 21, 2015

138

IM Setting INMEMORY
Create EMP and put it into the IM:
SQL> CREATE TABLE emp8

(EMPNO number, ENAME varchar2 (30)) INMEMORY;


Table created.

Alter DEPT table to be in the IM:


SQL> ALTER TABLE dept INMEMORY;
Table altered.

SQL> ALTER TABLE EMP7, EMP8 INMEMORY


ALTER TABLE EMP7 EMP8 INMEMORY
*

October 21, 2015

ERROR at line 1: ORA-01735: invalid ALTER TABLE option

139

Check IM in USER_TABLES
SQL> alter table emp inmemory;
Table altered.

select table_name, inmemory, inmemory_priority,


inmemory_compression
from user_tables
where table_name = 'EMP'
TABLE_NAME

INMEMORY INMEMORY_P INMEMORY_COMPRESS

---------------------------- -------- ----------- ----------------October 21, 2015

EMP

ENABLED

NONE

FOR QUERY LOW

140

Running queries using IM


Execution Plans for IM (may use IM for this query):
SELECT EMPNO
FROM EMP

ORDER BY EMPNO;
EMPNO
---------7839

---------------------------------------------------------------------------| Id | Operation

|Name |

-----------------------------------------------------------------------------

| 0 | SELECT STATEMENT

| 1 | SORT AGGREGATE

| 2 | PARTITION RANGE ALL


October 21, 2015

|* 3 | TABLE ACCESS INMEMORY FULL| EMP |


-------------------------------------------

141

IM Alter object to use it


Place entire tablespace (puts tables/partitions/mv into IM:
SQL> ALTER TABLESPACE tbcsp1 INMEMORY;
Instantly remove the emp table from the IM column store:
SQL> ALTER TABLE emp NO INMEMORY;
Instantly remove D1 Partition(dept) from IM column store:
SQL> ALTER TABLE dept MODIFY PARTITION d1 NO
INMEMORY;
A partitioned table automatically inherits whether or not the table is IM. You
can remove the D1 partition on the DEPT table from the IM immediately:
October 21, 2015

142

IM Exclude Columns from IM


Exclude some columns from going into the IM (default
is all columns go into IM):

SQL> ALTER TABLE emp INMEMORY NO


INMEMORY (ename, job, mgr, hiredate, deptno, sal,
comm);
Table altered.

The example above shows how to only put empno


column into the IM Column Store
October 21, 2015

143

IM Priority Levels
Change the Priority Level: Objects are populated based on priority
or immediately if they are accessed. The priorities that you can set
are:
CRITICAL Populated upon database opening
HIGH Populated after CRITICAL if space exists in IM
MEDIUM After CRITICAL/HIGH if space exists in IM
LOW - After CRITICAL/HIGH/MEDIUM if space exists
NONE (default) Populated only when accessed for the first time
if space exists in IM
October 21, 2015

144

IM Priority Levels
Populate the EMP table upon database startup (when open):
ALTER TABLE emp INMEMORY PRIORITY CRITICAL;
Table altered.

Populate the EMP table upon first access:


ALTER TABLE emp INMEMORY
Table altered.

October 21, 2015

145

In-Memory Compression Units (IMCUs) similar to Exadata Hybrid


Columnar Compression (HCC)
1. Column Data Compressed

Column1

Column1

Column 1

Column1

2. Stored in In Memory Compression Units (IMCUs)


(Columnizes/Comresses a set number of rows(100K?) in 1M chunks )

October 21, 2015

** Thanks Oracle for these images (modified)

(Warehouse)

(Archive)

146

IM - Compression
Compression Level when populating the IM :
NO MEMCOMPRESS Populate IM without compressing
MEMCOMPRESS FOR DML Minimal compression for DML
MEMCOMPRESS FOR QUERY LOW Optimized for query (DEFAULT)
MEMCOMPRESS FOR QUERY HIGH Optimized for query but save more
space
MEMCOMPRESS FOR CAPACITY LOW Balanced with bias toward
saving space (+OZIP)
MEMCOMPRESS FOR CAPACITY HIGH Optimized for best space
savings (slowest)
Usually get 2-20x; Ive seen 50x+
October 21, 2015

147

IM IMCUs & Compression


Create the EMP table using the IM, with compression settings for
QUERY, not populating DEPTNO column, and compressing the
ename column at higher level:
CREATE TABLE emp77 (EMPNO number(4), ENAME
varchar2(10), DEPTNO number (2))
INMEMORY MEMCOMPRESS FOR QUERY HIGH
NO INMEMORY(deptno)
INMEMORY MEMCOMPRESS FOR CAPACITY HIGH(ename);

Table created.
October 21, 2015

148

IM - Storage Indexes
IM Storage Indexes:
IM storage indexes are created and maintained on each column
in the IMCUs regardless of the compression.
Automatically created by Oracle (like Exadata).
They are used to prune the data by checking the min/max values
in each IMCU (In Memory Compression Units)
To evaluate WHERE clause: equality/in-list/some range)
In Exadata, ORDERED data in the table matters a lot will it also
matter in IM not sure yet
October 21, 2015

149

Bloom Filters in IM - FYI


A Bloom Filter created based on join & applied to the second table
as the first table is loaded as a hash table into memory (PGA) (note the BF=Bloom Filter - below). In a multi-table join many
Bloom Filters can be created.
---------------------------------------------------------------------------------| Id | Operation

| Name |

---------------------------------------------------------------------------------| 0 | SELECT STATEMENT

| 1 | SORT AGGREGATE

|* 2 | HASH JOIN

| 3|
|* 4 |

| 5|
October 21, 2015

|* 6 |

JOIN FILTER CREATE

| :BF0000 |

TABLE ACCESS INMEMORY FULL | EMP |

JOIN FILTER USE

| :BF0000 |

TABLE ACCESS INMEMORY FULL | DEPT |

150

IM with CDB/PDB
All PDBs within a CDB share a single IM column store
INMEMORY_SIZE initialization parameter on the CDB
Each PDB also sets an INMEMORY_SIZE and anything put in IM comes from total
CDBs IM setting
All PDBs added together can be higher than CDBs IM size (over-subscribed);
Memory is used on a first come basis by design to ensure this CDB IM is not
wasted
One PDB can take up entire CDB IM & starves others
Each PDB has its own PRIORITY list (which PDB starts first will matter A LOT!).
When out of space - you are out! until PDB shut down or something removed.
October 21, 2015

151

IM Effects of DML FYI


Consistency when DML occurs in Buffer Cache:
IM Transaction Manager will ensure IM is updated with transactions as they occur
No logging needed in IM - Buffer Cache takes care of that.
Records are marked stale (when changed in the buffer cache) in the IMCU (1M) of the IM and
new record is inserted in the IM Transaction Journal.
The original and new values are both present for transactional consistency and are coordinated
using SCNs (System Change Numbers) as in the buffer cache (it may also get the value from the
buffer cache).

October 21, 2015

152

IM Effects of DML FYI

12.1.0.

Consistency when DML occurs in Buffer Cache:


The IM will be repopulated if a staleness threshold is reached by a low priority
background process (based on IMCU & amount of stale rows).
INMEMORY_TRICKLE_REPOPULATE_SERVERS_PERCENT is max % of time worker can
participate in trickle repopulation (wakes up every 2 minutes). It can also be set to 0
to disable trickle repopulation.
Consistency costs depend on things like compression level, rate of change, location
of records, and type of operation.
Changes within the same IMCU are the least costly.
October 21, 2015

153

IM and RAC FYI


RAC has multiple SGAs (on each node) and has multiple IMs
Can have different IM sizes (recommend they are the same)
Can have different IM data in different nodes
Large tables can span nodes
By default it DISTRIBUTES between the nodes.
Can have same data on every node in IM DUPLICATE but
ONLY on Engineered Systems (later example)
You can DISTRIBUTE (by rowid, partition, or subpartition):
ALTER TABLE emp INMEMORY DISTRIBUTE BY PARTITION;
October 21, 2015

154

IM and RAC FYI


Distributing is especially good for partition-wise joins with
partitions/subpartitions
Single objects in a 1M IMCUs will be on only 1 node
If row is updated on different node cache fusion will be used to
update IM
Oracles RAC work from the past is beneficial
Space should be left in each IM in RAC to ensure if one of the
nodes goes down, the others will be able to populate INMEMORY
objects from the down node as they are accessed.
October 21, 2015

155

IM & RAC- Duplicate FYI


Mirroring the IM for fault tolerance (engineered systems):
(duplication of emp on a second node IM)
SQL> ALTER TABLE emp INMEMORY DUPLICATE;
Table altered.

SQL> ALTER TABLE emp INMEMORY DUPLICATE ALL;


Table altered.

(Full duplication of ALL objects in IM for complete fault tolerance all


nodes & linear scaling ignored if not an engineered system)
October 21, 2015

156

IM & RAC FYI


Duplicate & Fault Tolerance

Duplicate in-memory
columns on one other
node (DUPLICATE ALL
will duplicate on all nodes)
Enabled per
table/partition

Application
transparent

October 21, 2015

Downtime eliminated by
using duplicate after failure

RAC
Thanks Oracle: Graphics

157

IM Hints FYI
/*+ INMEMORY(table) */
/*+ NO_INMEMORY(table) */ (or NO INMEMORY??)
/*+ INMEMORY_PRUNING(table) */ (Control the use of the IM Storage Index)
/*+ NO_INMEMORY_PRUNING(table) */ (Control the use of the IM Storage Index)
/*+ PX_JOIN_FILTER(table) */ (force the use of a Bloom Filter for a join if optimizer
doesnt)
/*+ NO_PX_JOIN_FILTER(table) */ (force the NON-use of a Bloom Filter for a join if
optimizer doesnt)
/*+ VECTOR_TRANSFORM */ (force the use of the VECTOR GROUP BY - see
earlier section not in docs!)
October 21, 2015

158

IM Bulk Data Loads FYI


Bulk Data Loads:
If an IM table has PRIORITY set and a bulk data load
occurs, once committed, the new added data will be
populated to the IM
If PRIORITY is not set then the IM will not be
updated until the next access).
Before this action (populate new data), but after data
is committed, you can see the
BYTES_NOT_POPULATED column in
V$IM_SEGMENTS.
October 21, 2015

159

IM Partition Exchange FYI


Partition Exchange Loads:
Loading a temporary non-partitioned table and doing a partition
exchange into a partitioned table is a great way to load data into
particular partition of a partitioned table.
It does not physically move it or create redo/undojust updates
data dictionary pointers (less costly).
If the temporary table had IM set, it will continue to be IM in the
partitioned table (now part of partitioned table).
If temporary table is not IM, then it will use the buffer cache (has
to be set on temporary table before the exchange
Setting IM on the empty partition will NOT do it.
October 21, 2015

160

IM Key Initialization Parameters FYI


Key Initialization Parameters:
INMEMORY_SIZE - The size of the column store (default 0;
minimum 100M). If set to zero, it is not being used! System
level and requires restart if changed.
INMEMORY_QUERY - Enabled by default and means that the
Optimizer will use the IM for queries if enabled (see above). If
disabled at system or session level, then optimizer will not direct
queries to use the IM.

ALTER SESSION SET INMEMORY_QUERY=DISABLE;


(stop using the IM)
October 21, 2015

161

IM Key Initialization Parameters FYI


INMEMORY_MAX_POPULATE_SERVERS - Number of workers
used to populate the IM Column Store. Default is
0.5xCPU_COUNT. Slows down repopulation if lowered.
INMEMORY_FORCE If set to OFF, the IM will not be
populated no matter what the object settings are. The default is
DEFAULT which allows normal population.
INMEMORY_CLAUSE_DEFAULT Set defaults to be different.
For example, change the default compression
ALTER SYSTEM SET INMEMORY_CLAUSE INMEMORY PRIORITY HIGH;

INMEMORY_TRICKLE_REPOPULATE_SERVERS_PERCENT DEFAULT

is 1% (see notes on previous slides)


October 21, 2015

162

IM V$ Views for more info FYI


Get more information:
V$IM_SEGMENTS, V$IM_USER_SEGMENTS,
V$IM_COLUMN_LEVEL, USER_TABLES, also the deep dive at
V$KEY_VECTOR (took an Oraco
USER_TABLES (inmemory, inmemory_priority,
inmemory_compression, inmemory_distribute,
inmemory_duplicate)
Resource Manager can also be used to manage the CPU
resources when populating the IM.
Cant be used on Active Data Guard standby instance, but can be
used on Logical Standby instance using Golden Gate.
October 21, 2015

163

Other 12c Features


Database Instance Smart Flash Cache Support for Multiple Devices (can access/combine) without the overhead of the local volume
manager.
Supports In-Memory Jobs & In-Memory Temporary Tablespaces

Active Data Guard Security has in-memory table of failed login attempts
Heat Map that tracks modifications of rows (block level), table, partition levels
Automate policy-driven data movement and compression using Heat Map
Move partitions while ONLINE with DML happening / Flex ASM to other storage
Improved query performance against OLAP cubes (especially Exadata)
Automatic extended stats for groups of columns accessed together
DBMS_STATS.GATHER_TABLE_STATS run on a partitioned table when CONCURRENT is set to TRUE will gather stats using
multiple jobs concurrently
Online statistics gathered during a bulk load (similar to rebuild index command)

Flashback Data Archive (FDA) can be fully used on HCC tables on Exadata
Enterprise Manager Database Express 12c ships with every database (NICE!)
Spot ADDM triggered by high CPU or I/O into AWR Reports
Mask Data At Source for testing & Oracle Masking templates for E-Business

Oracle Data Redaction (prevents things like SSN from being displayed)
October 21, 2015

164

Other 12c Features


Full Transportable support & Point-in-time recovery for PDBs
TRUNCATE TABLE CASCADE (truncate child tables too)
Data Pump No Logging Option for import
No-echo of Encryption Passwords on expdp/impdp commands
Sql*Loader Express Mode no control file!
In-Database MapReduce (Big Data)
Update strong user authentication using kerberos & Simplified Vault administration
Many Windows enhancements (if you must use Windoze)
Fast Application Notification (FAN) gets improved with Application Continuity which helps recover incomplete
requests without executing more than once.
Real-Time Apply (redo) is now default for Data Guard vs. applying archive logs
SQL Apply Support for Objects, Collections, XML Type, & SecureFiles LOBs
Oracle Spacial is now Oracle Spacial & Graph Enhancements include routing engine enhancements, caching of
index metadata, vector performance, Asian address support (geocoding), raster algebra & analytics, enhance
image processing
Many ACFS, Oracle Multimedia, Oracle Text & Oracle XML enhancements
October 21, 2015

VARCHAR2(32767) not default/4K stored inline/>4K out of line(like a LOB)

165

Addressable Memory Growth


Shift
8-bit to 16-bit
16-bit to 32-bit
32-bit to 64-bit
64-bit to 128-bit

October 21, 2015

Increase (Result)
1 mph (Windows)
65K mph (Internet)
300T mph (Robotics/3Detc.)
5T*T*B mph

166

How Big?

October 21, 2015

167

Whats Coming Next Robotics,


3D & IOT = IOE = M:M
Internet Of Things (IOT)
Internet Of Everything (IOE)
Machine to Machine (M:M)

Wednesday
Big Data/IOT / The Future:
1:45 2:30 MS 103

October 21, 2015

168

Google/Cyberdyne augments people/tech


Be a Future Tech Leader!
(Integrating Tech)

October 21, 2015

169

Summary 12c Database


Know the Oracle!
Start Me Up Using Memory Target, The Buffer Cache & The Result Cache
Invisible Columns (12c) & virtual columns (11g)
Multiple indexes on the same Column (12c) & Invisible Indexes (11g)
Runaway query Management (12c)
Change Table Compression at import Time (12c)
Create Views as Tables (12c)
Pluggable Databases (12c)
Enhanced DDL Online (12c)
Automatic Diagnostics Repository (12c)
Security Enhancements (12c)
Oracle Database In-Memory (12c+)
Other 12c New Features
October 21, 2015

170

We make a Living by what we get;

We make a Life by what we give.

Dedicated to the memory of Mark Townsend & Gary Goodman


October 21, 2015

171

Oracle is never caught from behind

Oracles 38th Anniversary in 2015

October 21, 2015

Great Sales/Marketing
Great Database
Applications Leader
BI Leader /
Already in the lead
Game Over!
Hardware/Software Engineering!
172

SIG Meetings at Oracle OpenWorld


All meetings will be held in User Group Pavilion, Meeting Room, Moscone South
Monday, October 26
IOUG Cloud Computing SIG Meet-Up: 10:00 a.m.11:00 a.m.
IOUG Oracle Enterprise Manager SIG: 5:00 p.m.6:00 p.m. *Location: OTN Lounge, Moscone South*
Tuesday, October 27
IOUG IoT SIG: 10:30 a.m.11:30 a.m.
IOUG BIWA SIG: 11:30 a.m.12:30 p.m.
Wednesday, October 28
IOUG Exadata SIG: 10:30 a.m.11:30 a.m.
IOUG RAC SIG: 1:00 p.m.2:00 p.m.
IOUG Oracle 12c SIG: 2:00 p.m.3:00 p.m.

My Presentations at OpenWorld 2015


Sunday:
12c Best New Features
12c Best Tuning Features

9:00 9:45 AM MS 305


11:00 - 11:45 AM MS 304

Monday:
The Best 12c Database Features 10:30 - 11:00 AM Rolta Booth #1701
Enter to Win an iPad Air
Rolta Booth #1701
Tuesday:
Innovation, Big Data & IOT Brief 3:15 3:35 PM Rolta Booth #1701
Enter to Win an iPad Air
Rolta Booth #1701
Wednesday:

Innovation, Big Data & IOT 1:45 - 2:30 PM MS 103


All Booth Presentations at Rolta Booth # 1701 in Moscone South Vendor Hall

October 21, 2015

174

For More Information


Oracle 11g Release 2 Performance
Tuning Tips & Techniques; Richard J.
Niemiec; Oracle Press (Available now)
Working on 12cR2 Now!

October 21, 2015

If you are going through hell, keep going - Churchill

175

#1 Selling Oracle Database Book on Amazon for 2 years after release!


Also available at other places
like Barnes & Nobleetc.
Available on the Kindle and
other book readers
Why is it #1?

October 21, 2015

176

Database References
Oracle 12c Beta Documentation & Beta Database
Oracle11g Performance Tuning Tips & Techniques; Richard J. Niemiec; Oracle Press
www.tusc.com. www.rolta.com
Database Secure Configuration Initiative: Enhancements with Oracle Database 11g,
www.oracle.com
All Oracle11g Documentation from Oracle Beta Site
Introduction to Oracle Database 11g, Ken Jacobs
Oracle Database 11g New Features, Linda Smith
New Optimizer Features in 11g, Maria Colgan
www.ioug.org, www.oracle.com, en.wikipedia.org & technet.oracle.com
Thanks Dan M., Bob T., Brad, Joe, Heidi, Mike K., Debbie, Maria, Linda
All companies and product names are trademarks or registered trademarks of the respective
owners
October 21, 2015

177

Exadata References
Exadata V2 Sun Oracle DB Machine, Oracle
Oracle Exadata Implementation Workshop, Oracle Corporation, McLean, Virginia - Multiple Exadata
sessions

Oracle Learning Library multiple sessions/topics


Oracle 11g R1/R2 Best Features, Rich Niemiec
Oracle Enterprise Manager Deployment and High Availability Best Practices, Jim Viscusi (Oracle
Corporation), Jim Bulloch (Oracle Corporation), Steve Colebrook-Taylor (Barclays Global Investors)

Oracle11g Performance Tuning Tips & Techniques, Rich Niemiec, Oracle Press McGraw-Hill
Advanced Compression with Oracle Database 11g Release 2, Oracle Corporation, Steven Lu
Tech Crunch
Twilight Zone Series
Rod Serling; Submitted for Your Approval, American Masters
YouTube/oracle Oracle OpenWorld On Demand

October 21, 2015

178


Oracle9i Tuning (May 2003)
Oracle10g Tuning (June
2007)
Oracle11g Tuning (Jan 2014)

October 21, 2015

- Henry David Thoreau

179

You might also like