Sie sind auf Seite 1von 47

Oracle Database 12.1.0.

2: New Features
Prepared by:
Deiby Gmez
Oracle Certified Master 11g
Pythian Oracle Database Consultant
2 2014 Pythian Confidential
ADVANCED INDEX COMPRESSION
CREATE INDEX ()ON() COMPRESS ADVANCED LOW;

NO COMPRESSION
dgomez, Guatemala, 1
Jose, Canada, 1
Lucky, Mexico, 2
Performance
Compression

dgomez, Guatemala, 2
dgomez, guatemala, 3

WITH COMPRESSION
$$, 1 Prefix: $$
Jose, Canada, 1
Lucky, Mexico, 2
$$, 2
$$, 3
Its good with so many repeated values

3 2014 Pythian Confidential


ADVANCED INDEX COMPRESSION
kdxlepnro 3 <--How many prefixes exist
kdxlepnco 1 (Adaptive) <--How many columns are being compressed
prefix row#0[8023] flag: -P-----, lock: 0, len=9
col 0; len 6; (6): 43 61 6e 61 64 61 <--'Canada'
prc 1
prefix row#1[8003] flag: -P-----, lock: 0, len=11
col 0; len 8; (8): 43 6f 6c 6f 6d 62 69 61 <--'Colombia'
prc 1
prefix row#2[7982] flag: -P-----, lock: 0, len=12
col 0; len 9; (9): 47 75 61 74 65 6d 61 6c 61 <-- 'Guatemala'
prc 1
row#0[8014] flag: -------, lock: 0, len=9
col 0; len 6; (6): 01 80 00 dd 00 01 <-- Sufix
psno 0 <--Prefix #0
row#1[7994] flag: -------, lock: 0, len=9
col 0; len 6; (6): 01 80 00 dd 00 02 <-- Sufix
psno 1 <--Prefix#1
row#2[7973] flag: -------, lock: 0, len=9
col 0; len 6; (6): 01 80 00 dd 00 00 <-- Sufix
psno 2 <--Prefix #2
----- end of leaf block Logical dump -----
----- end of leaf block dump -----

4 2014 Pythian Confidential


ADVANCED INDEX COMPRESSION

CREATE INDEX my_test_idx ON test(a, b)


COMPRESS ADVANCED HIGH LOCAL
(PARTITION p1 COMPRESS ADVANCED LOW,
PARTITION p2 COMPRESS,
PARTITION p3,
PARTITION p4 NOCOMPRESS);

5 2014 Pythian Confidential


ADVANCED INDEX COMPRESSION
How does it work? At the block level in the following situations:

During index creation when a leaf block becomes full


When reorganizing an index block as a result of DML (block split may
not occur)

Restrictions:

Its not supported for bitmap indexes or index-organized tables.


It cannot be specified on a single column unique index. WHY?

6 2014 Pythian Confidential


APPROXIMATE COUNT DISTINCT

COUNT(DISTINCT expression)

Cost

7 2014 Pythian Confidential


APPROXIMATE COUNT DISTINCT

SQL> select APPROX_COUNT_DISTINCT(col1) aprox_col1 from dgomez.t1

APROX_COL1
----------
92611

------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost(%CPU)| Time |
------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 13 | 137 (1) |00:00:01|
| 1 | SORT AGGREGATE APPROX| | 1 | 13 | | |
| 2 | TABLE ACCESS FULL | T1 | 249K | 3166K | 137 (1) |00:00:01|
------------------------------------------------------------------------

8 2014 Pythian Confidential


ATTRIBUTE CLUSTERING

An attribute-clustered table stores data in close


proximity on disk in an ordered way based on the
values of a certain set of columns in the table or a set of

columns in the other tables.

9 2014 Pythian Confidential


ATTRIBUTE CLUSTERING
Types of Attribute Clustering
Attribute Clustering with Linear Ordering
Attribute Clustering with Interleaved Ordering

When occurs?
Direct-path insert operations - Set the ON LOAD option to YES
Data movement operations - Set the ON DATA MOVEMENT
option to YES
o online table redefinition
o partition operations:
MOVE
MERGE
SPLIT
COALESCE

10 2014 Pythian Confidential


ATTRIBUTE CLUSTERING

11 2014 Pythian Confidential


ATTRIBUTE CLUSTERING - ADVANTAGES

Eliminates storage costs associated with using indexes


Enables the accessing of clustered regions rather than performing random
I/O or full table scans when used in conjunction with zone maps
Provides I/O reduction when used in conjunction with any of the following:
Oracle Exadata Storage Indexes
Oracle In-memory min/max pruning
Zone maps
Enables clustering of fact tables based on dimension columns in star
schemas
Improves data compression ratios and in this way indirectly improves table
scan costs
Minimizes table lookup and single block I/O operations for index range scan
operations when the attribute clustering is on the index selection criteria.

12 2014 Pythian Confidential


AUTOMATIC BIG TABLE CACHING

Big table cache is used for caching data for table scans.
Automatic big table caching uses temperature and object based
algorithms to track medium and big tables.

How to enable it?

DB_BIG_TABLE_CACHE_PERCENT_TARGET
o percentage [0%,90%]
o 10% of cache for No table scans
PARALLEL_DEGREE_POLICY =AUTO | ADAPTIVE (RAC)

13 2014 Pythian Confidential


AUTOMATIC BIG TABLE CACHING

If a large table is approximately the size of the combined size of the big table
cache of all instances, then the table is partitioned and cached, or mostly
cached, on all instances.

Where to check information about big table caching?

V$BT_SCAN_CACHE
V$BT_SCAN_OBJ_TEMPS

14 2014 Pythian Confidential


FDA SUPPORT FOR CDBS

In Release 12.1.0.1, Flashback Database Archive


was not supported for multitenant container
databases (CDBs).

In Release 12.1.0.1, Flashback Database Archive


(FDA) is supported for CDBs

15 2014 Pythian Confidential


FULL DATABASE CACHING

DB size > Buffer Cache


Little tables:
Allocated in memory If the table size < 2% of the Buffer Cache size

Medium tables:
Allocated in memory if table size [2%,10%] of Buffer Cache size (No
official information)
Oracle analyze the date when the table was used last time
Free space in Buffer Cache
Etc

Big Tables
Big tables are not allocated in Buffer Cache
Use "KEEP to advice Oracle to allocate a big table in Buffer Cache

16 2014 Pythian Confidential


FULL DATABASE CACHING

Buffer Cache > DB size


Little tables:
Allocated in memory If the table size < 2% of the Buffer Cache size

Medium tables:
Allocated in memory if table size [2%,10%] of Buffer Cache size (No
official information)
Oracle analyze the date when the table was used last time
Free space in Buffer Cache
Etc

Big Tables
Big tables are not allocated in Buffer Cache
Use "KEEP to advice Oracle to allocate a big table in Buffer Cache

17 2014 Pythian Confidential


FULL DATABASE CACHING
Buffer Cache > DB size

Tables are not allocated in Buffer Cache immediately


Buffer Cache must be bigger than DB (Oracle doesnt verify this)

Is Full Database Caching enabled?

SQL> SELECT FORCE_FULL_DB_CACHING FROM V$DATABASE;

FORCE_FULL_DB_CACHING
---------------------
YES

18 2014 Pythian Confidential


FULL DATABASE CACHING
Buffer Cache > DB size

What about if I enable it but Buffer Cache !> DB Size?

Algorithms to allocate small, medium and large tables are not used.
More Objects Deallocation
New object scanned, blocks deallocated.

19 2014 Pythian Confidential


FULL DATABASE CACHING
How to enabled it?
SQL> shutdown immediate;
SQL> startup mount;
SQL> ALTER DATABASE FORCE FULL DATABASE CACHING;
SQL> alter database open;

How to disable it?


SQL> shutdown immediate;.
SQL> startup ;
SQL> ALTER DATABASE NO FORCE FULL DATABASE
CACHING;
SQL> alter database open;

20 2014 Pythian Confidential


IN-MEMORY COLUMN STORE

A DBA simply has to allocate memory to In-Memory


Column Store. The optimizer is aware of In-Memory
Column Store, so whenever a query accesses objects that
reside in the column store, Optimizer takes advantage of

that.

21 2014 Pythian Confidential


IN-MEMORY COLUMN STORE
How to enable it?

The INMEMORY_SIZE initialization parameter must be set to a non-zero value.


-Minimum 100M.-

IM column store can be enabled at any of the following levels:

Column
Table
Materialized view
Tablespace
Partition

22 2014 Pythian Confidential


IN-MEMORY COLUMN STORE
Advantages:

A query that uses operators such as the following: =, <, >, and IN
A query that selects a small number of columns from a table or materialized
view with a large number of columns

A query that joins a small table to a large table

INMEMORY PRIORITY Subclause

PRIORITY NONE
PRIORITY LOW
PRIORITY MEDIUM
PRIORITY HIGH
PRIORITY CRITICAL

23 2014 Pythian Confidential


JSON SUPPORT

24 2014 Pythian Confidential


JSON SUPPORT

You can access JSON data stored in the database the same
way you access other database data

Unlike XML data, which is stored using SQL data type


XMLType, JSON data is stored in Oracle Database using SQL

data types VARCHAR2, CLOB, and BLOB

25 2014 Pythian Confidential


NEW FIPS 140 PARAMETER FOR ENCRYPTION

FIPS 140-2 Security Requirements for Cryptographic Modules is a U.S.


government standard for implementation of cryptographic modules that
encrypt and decrypt data or perform other cryptographic operations (such

as creating or verifying digital signatures)


How to enable it?

ALTER SYSTEM SET DBFIPS_140 = TRUE;


shutdown immediate;
startup;

**sqlnet.ora

26 2014 Pythian Confidential


PDB CONTAINERS CLAUSE
SELECT ename
FROM CONTAINERS(scott.emp)
WHERE CON_ID IN (11, 13);

27 2014 Pythian Confidential


PDB CONTAINERS CLAUSE

The tables and views, or synonyms of them, specified in the


CONTAINERS clause must exist in the root and in all PDBs.

Each table and view specified in the CONTAINERS clause must


be owned by the common user.

When a synonym is specified in the CONTAINERS clause, the


synonym must resolve to a table or a view owned by the
common user issuing the statement.

28 2014 Pythian Confidential


PDB FILE PLACEMENT IN OMF

FILE_NAME_CONVERT clause of CREATE PLUGGABLE DATABASE

CREATE_FILE_DEST clause of CREATE PLUGGABLE DATABASE

DB_CREATE_FILE_DEST (root level)

PDB_FILE_NAME_CONVERT initialization parameter

29 2014 Pythian Confidential


PDB LOGGING CLAUSE

Table Level Logging

Index Level Logging

Tablespace Level Logging

Tablespace Level - Force Logging

PDB Level Logging

PDB Level - Force No logging

CDB - Force Logging

30 2014 Pythian Confidential


PDB LOGGING CLAUSE
SQL> alter session set container=pdb1;
SQL> startup restrict;
SQL> alter pluggable database pdb1 nologging;

SQL> alter pluggable database pdb1 logging;

SQL> select pdb_name, logging, force_logging,


force_nologging from cdb_pdbs;

PDB_NAME LOGGING FORCE_LOGGING


FORCE_NOLOGGING
---------- --------- ---------------
---------------
PDB1 LOGGING NO NO

31 2014 Pythian Confidential


PDB METADATA CLONE
NO DATA clause of the CREATE PLUGGABLE DATABASE

This clause is useful for quickly creating clones of a PDB


with only the object definitions and no data.

32 2014 Pythian Confidential


PDB REMOTE CLONE

IN SOURCE DB:

**alter pluggable database pdbsource open read only;

create user C##dgomez identified by manager1;

grant create session to C##dgomez;

33 2014 Pythian Confidential


PDB REMOTE CLONE
IN TARGET DB:
create user C##dgomez identified by manager1;
grant create session, create database link, create pluggable
database to C##dgomez;

PDBSOURCE =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = db12102.oraworld.com)(PORT =
1521))
(CONNECT_DATA =
(SERVER = DEDICATED)(SERVICE_NAME = pdbsource)
))

create database link dblinktosource connect to C##dgomez identified


by manager1 using 'PDBSOURCE';

create pluggable database pdbtarget3 from pdbsource@dblinktosource;

34 2014 Pythian Confidential


PDB REMOTE CLONE
Target: 12.1.0.2
Source: 12.1.0.1

SQL> create pluggable database pdbtarget from


pdbsource@dblinktosource;
*
ERROR at line 1:
ORA-17627: ORA-00600: internal error code, arguments:
[ksrpcsexec_1], [158],
[20], [], [], [], [], [], [], [], [], []
ORA-17627: ORA-00600: internal error code, arguments:
[ksrpcsexec_1], [158],
[20], [], [], [], [], [], [], [], [], []

35 2014 Pythian Confidential


PDB REMOTE CLONE
Target: 12.1.0.1
Source: 12.1.0.1

SQL> create pluggable database pdbtarget from


sourcepdb@dblinktosource
*
ERROR at line 1:
ORA-17628: Oracle error 19505 returned by remote Oracle server
ORA-19505: failed to identify file ""

36 2014 Pythian Confidential


PDB REMOTE CLONE
Target: 12.1.0.2
Source: 12.1.0.2

SQL> create pluggable database pdbtarget from


pdbsource@dblinktosource;

Pluggable database created.

37 2014 Pythian Confidential


PDB STANDBYS CLAUSE
Primary Standby

PDB1 PDB1

Datafiles Offline
PDB2 PDB2 Unnamed

PDB3 PDB3

38 2014 Pythian Confidential


PDB STANDBYS CLAUSE

The STANDBYS clause of the CREATE PLUGGABLE DATABASE


statement specifies whether the new PDB is included in standby CDBs

STANDBYS=ALL includes the new PDB in all of the standby CDBs


.
STANDBYS=NONE excludes the new PDB from all of the standby
CDBs.

39 2014 Pythian Confidential


PDB STANDBYS CLAUSE

It is possible to enable a PDB on a standby CDB after it was


excluded on that standby CDB.

PDB data files need to be copied to the standby database from the
primary database

The control file needs to be updated to reflect their paths

Execute ALTER PLUGGABLE DATABASE ENABLE RECOVERY


It automatically onlines all of the data files belonging to the PDB.

40 2014 Pythian Confidential


PDB STATE MANAGEMENT ACROSS CDB RESTART

12.1.0.1

Source: "Oracle Database 12c: New Features for Administrators by Oracle University

41 2014 Pythian Confidential


PDB STATE MANAGEMENT ACROSS CDB RESTART

12.1.0.2
1. Set the PDB at the State you want to save.

2. SQL> alter pluggable database pdb1 save state;

Pluggable database altered.

or

SQL> alter pluggable database pdb1 discard state;

Pluggable database altered.

42 2014 Pythian Confidential


PDB STATE MANAGEMENT ACROSS CDB RESTART

12.1.0.2

SQL> ALTER PLUGGABLE DATABASE ALL EXCEPT PDB1 SAVE STATE;

Pluggable database altered.

SQL> ALTER PLUGGABLE DATABASE ALL SAVE STATE;

Pluggable database altered.

43 2014 Pythian Confidential


PDB SUBSET CLONING

The USER_TABLESPACES clause of the CREATE PLUGGABLE


DATABASE statement specifies which tablespaces are available in the new

PDB
o List one or more tablespaces to include.

o Specify ALL, the default, to include all of the tablespaces.

o Specify ALL EXCEPT to include all of the tablespaces, except for


the tablespaces listed.

o Specify NONE to exclude all of the tablespaces.

44 2014 Pythian Confidential


PDB SUBSET CLONING PDB 1
Tablespace 1

Database Source
PDB 2
Tablespace 1 Tablespace 2

Tablespace 2

Tablespace 3
PDB 3
Tablespace 3

45 2014 Pythian Confidential


REFERENCES
Una Introduccin a "Oracle Advanced Index Compression"
http://www.toadworld.com/platforms/oracle/b/weblog/archive/2015/04/28/una-introducci-
243-n-a-advanced-index-compression
Oracle 12.1.0.2 y la funcin APPROX_COUNT_DISTINCT
http://www.toadworld.com/platforms/oracle/b/weblog/archive/2015/07/29/oracle-12-1-0-2-
y-la-funci-n-approx-count-distinct
Logging Levels in Oracle 12c
http://www.toadworld.com/platforms/oracle/b/weblog/archive/2015/08/01/logging-levels-
in-oracle-12c
Cmo clonar una PDB desde un CDB remoto
http://www.toadworld.com/platforms/oracle/b/weblog/archive/2015/05/13/c-243-mo-
clonar-una-pdb-desde-un-cdb-remoto
Cmo hacer persistente el estado de una PDB
http://www.toadworld.com/platforms/oracle/b/weblog/archive/2015/04/30/c-243-mo-
hacer-persistente-el-estado-de-una-pdb
Oracle Documentation 12.1.0.2
http://docs.oracle.com/database/121/NEWFT/chapter12102.htm#NEWFT003

46 2014 Pythian Confidential


Thanks for
coming!
Questions?
Twitter: @hdeiby
Facebook: /HDeiby
Email: gomez@pythian.com
Blog: www.oraclefromguatemala.com.gt

47 2014 Pythian Confidential