51
The top 12 new features of Oracle 12c! David Yahalom, CTO, NAYA Technologies www.naya-tech.com Email: [email protected]

Oracle12 - The Top12 Features by NAYA Technologies

Embed Size (px)

Citation preview

The top 12 new features of Oracle 12c!

David Yahalom, CTO, NAYA Technologies www.naya-tech.com

Email: [email protected]

About NAYA Technologies

• Founded in 2009, NAYA technologies provides database consulting, training and Data Platform managed services.

• The company is headquartered in Israel and New York and specializes in planning, deploying, and managing business critical database systems for large enterprises and leading startups.

• NAYA is one of the fastest growing boutique consulting companies inthe market with teams that provide clients with the peace of mind they need when it comes to their critical data and database systems.

2

Our Services and Solutions (FOCUS)

SQL ServerDatabase

NAYA has years of experience in implementingData Platform technologies across different industries.

BigData and NoSQL

High Availability

Training Services NAYA College

Oracle Database

Business Intelligence

MySQL and PostgreSQL

Databases in the Azure / AWS

Clouds

Database Security

3

Oracle Engineered SolutionsData Integration

High Performance Database Tuning

• Oracle RealWorld Performance Tuning!• A very practical seminar designed to provide its participants

with a simple methodology and a clear understanding of the Oracle tuning process.

• 1. How to best identify our problematic SQL.

• 2. The most powerful and actually useful tools for performance tuning

• 3. Discuss real world examples of performance tuning issues and their solutions!

• 4.We will also get to know some of the best Oracle 12c new features for better performance.

• Oracle RealWorld Performance Tuning!• > Identifying the high load SQL statements• GUI performance tools (OEM), AWR report, Oracle Tracing

• > Tools for retrieving execution plans and execution statistics• Autotrace, DBMS_XPLAN, EXPLAIN PLAN FOR, Developers

Graphical tools

• > Understanding execution plans• How to read execution plans? – What should we look for to

identify core issues?

• > Affecting execution plans to resolve performance issues Hints, Optimizer statistics, Optimizer Parameters, re-writing the SQL and more

• Oracle RealWorld Performance Tuning!• > Execution plan real time statistics – Moving from theory to

actual

• > Using SQL Monitoring and the “Gather plan statistics” hint (View Actual values of the execution compared to the optimizer estimated ones)

• > Oracle 12c enhancements to SQL Monitoring

• Oracle RealWorld Performance Tuning!• > Stabilizing a good plan for my query using SQL Plan Baselines

• > Adding a hint to my query without changing the SQL in my code (Magic?)

• > Generating the Oracle performance reports (AWR, ASH etc) from developer client tools, and using them efficiently

• > Using the Oracle Result Cache to optimize performance

• > Additional tips and tricks for better performance

• Oracle RealWorld Performance Tuning!

• > Adaptive Execution plans.

• > Adaptive Statistics and re-optimizations.

• > Additional selected Oracle 12c new features for better performance.

• 50% discount of registration price using code:W2ATNDS

[email protected]

www.naya-tech.com | 5 Penn Plaza, 23rd floor Manhattan, New York 10001 +1.212.896.3945

Improved column defaults

SQL> create sequence s; Sequence created.

SQL> create table my_table 2 ( x int 3 default s.nextval 4 primary key, 5 y varchar2(30) 6 ); Table created.

• > Sequences supported for columns without a trigger!

www.naya-tech.com | 5 Penn Plaza, 23rd floor Manhattan, New York 10001 +1.212.896.3945

Improved column defaults• > We can now use an IDENTITY type!• • > Generates a sequence and associate that

sequence with the table.

create table my_Table (x int generated as identity primary key, y varchar2(30));

www.naya-tech.com | 5 Penn Plaza, 23rd floor Manhattan, New York 10001 +1.212.896.3945

Improved column defaults

create table t (x int generated by default as identity

(start with 42 increment by 1000 )

primary key, y varchar2(30))

• > Complex identity values supported

www.naya-tech.com | 5 Penn Plaza, 23rd floor Manhattan, New York 10001 +1.212.896.3945

Increased size limits> VARCHARS can go up to 32K!

Set MAX_STRING_SIZE init.ora parameter to EXTENDED.

Run @?/rdbms/admin/utl32k.sql

create table t ( x varchar(32767) );

>> Actually stored as LOB

>> In-row <= 4K, out of row > 4K…

www.naya-tech.com | 5 Penn Plaza, 23rd floor Manhattan, New York 10001 +1.212.896.3945

Increased size limits> But now you can use RPAD/LPAD/TRIM !

SQL> insert into my_tab values ( rpad('*',32000,'*') );

1 row created.

SQL> select length(x) from my_tab;

LENGTH(X) —————————————— 32000

(previously string built-in functions would have been able to return only 4,000 bytes)

www.naya-tech.com | 5 Penn Plaza, 23rd floor Manhattan, New York 10001 +1.212.896.3945

Improved top-N queries> New Row limiting clause for result set

pagination.

> Support for the ANSI-standard FETCH FIRST/NEXT and OFFSET

create table t as select * from all_objects;

create index t_idx on t(owner,object_name);

www.naya-tech.com | 5 Penn Plaza, 23rd floor Manhattan, New York 10001 +1.212.896.3945

Improved top-N queries> Retrieve the first five rows after sorting by

OWNER and OBJECT_NAME

select owner, object_name, object_id from t order by owner, object_name FETCH FIRST 5 ROWS ONLY;

www.naya-tech.com | 5 Penn Plaza, 23rd floor Manhattan, New York 10001 +1.212.896.3945

Improved top-N queries> The optimizer is rewriting the query to use

analytics!…——————————————————————————————————————————————————————————————————————————————| Id |Operation | Name|Rows |Bytes |Cost (%CPU)|Time |——————————————————————————————————————————————————————————————————————————————| 0|SELECT STATEMENT | | 5 | 1450 | 7 (0)|00:00:01||* 1| VIEW | | 5 | 1450 | 7 (0)|00:00:01||* 2| WINDOW NOSORT STOPKEY | | 5 | 180 | 7 (0)|00:00:01|| 3| TABLE ACCESS BY INDEX ROWID|T |87310 | 3069K| 7 (0)|00:00:01|| 4| INDEX FULL SCAN |T_IDX| 5 | | 3 (0)|00:00:01|——————————————————————————————————————————————————————————————————————————————

Predicate Information (identified by operation id):—————————————————————————————————————————————————————————————————

1 - filter("from$_subquery$_003"."rowlimit_$$_rownumber"<=5)2 - filter(ROW_NUMBER() OVER ( ORDER BY "OWNER","OBJECT_NAME")<=5)

www.naya-tech.com | 5 Penn Plaza, 23rd floor Manhattan, New York 10001 +1.212.896.3945

Improved top-N queries

> To paginate through a result set:(Get N rows at a time from a specific page in the result set

—add the OFFSET clause).

select owner, object_name, object_idfrom torder by owner, object_nameOFFSET 5 ROWS FETCH NEXT 5 ROWS ONLY;

www.naya-tech.com | 5 Penn Plaza, 23rd floor Manhattan, New York 10001 +1.212.896.3945

Temporary UNDO> Previously:

Temporary tablespace DML

Generates UNDO in the UNDO TBS(for read consistency)

UNDO TBS changes required REDO for crash recovery

www.naya-tech.com | 5 Penn Plaza, 23rd floor Manhattan, New York 10001 +1.212.896.3945

Temporary UNDO

Temp TBS

Redo logs

Undo TBS

Bulk Load

www.naya-tech.com | 5 Penn Plaza, 23rd floor Manhattan, New York 10001 +1.212.896.3945

Temporary UNDOTemp TBS & Temporary Undo

Redo logs

Undo TBS

Bulk LoadPermanent tables

Operations on temporary tables will no longer generate redo.

www.naya-tech.com | 5 Penn Plaza, 23rd floor Manhattan, New York 10001 +1.212.896.3945

Temporary UNDO> Can be used with Active DataGuard!

Read-only replicated tables

Read / Write temporary table(intermediate query results)

Source Database

www.naya-tech.com | 5 Penn Plaza, 23rd floor Manhattan, New York 10001 +1.212.896.3945

Temporary UNDOalter session set temp_undo_enabled = true;

update my_table set object_name = lower(object_name);

87310 rows updated.

Statistics ——————————————————————————————— … 0 redo size …

www.naya-tech.com | 5 Penn Plaza, 23rd floor Manhattan, New York 10001 +1.212.896.3945

New partitioning features

> Move a partition ONLINE! (non-blocking DDL, allow DML)

alter table test_tbl move partition p1 ONLINE;

www.naya-tech.com | 5 Penn Plaza, 23rd floor Manhattan, New York 10001 +1.212.896.3945

Transaction Guard> For database developers.

> API that returns the outcome of the last transaction.

> Provide protection for sensitive transactions that are allowed to only

happen once.

www.naya-tech.com | 5 Penn Plaza, 23rd floor Manhattan, New York 10001 +1.212.896.3945

Transaction Guard> Without:

www.naya-tech.com | 5 Penn Plaza, 23rd floor Manhattan, New York 10001 +1.212.896.3945

Transaction Guard

CallableStatement c = conn2.prepareCall( "declare b1 boolean; b2 boolean; begin" +"DBMS_APP_CONT.GET_LTXID_OUTCOME(?,b1," +"b2); ? := case when B1 then " +"'COMMITTED' else 'UNCOMMITTED' end; " +"end;");

www.naya-tech.com | 5 Penn Plaza, 23rd floor Manhattan, New York 10001 +1.212.896.3945

Transaction Guard> With:

www.naya-tech.com | 5 Penn Plaza, 23rd floor Manhattan, New York 10001 +1.212.896.3945

Adaptive Execution Plans> Before Oracle 12c, plans were fixed for the

first execution.> Unexpected high row counts may make first plan

suboptimal.

> With 12, the Optimizer can now generate plan + subplans.

> Optimizer picks final plan based on cardinality during first execution.

> “Changes its mind” in realtime!

www.naya-tech.com | 5 Penn Plaza, 23rd floor Manhattan, New York 10001 +1.212.896.3945

Adaptive Execution Plans

www.naya-tech.com | 5 Penn Plaza, 23rd floor Manhattan, New York 10001 +1.212.896.3945

Adaptive Execution Plans

-------------------------------------------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | -------------------------------------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | 23 | 4 (0)| 00:00:01 | | 1 | HASH UNIQUE | | 1 | 23 | 4 (0)| 00:00:01 | |- * 2 | HASH JOIN SEMI | | 1 | 23 | 4 (0)| 00:00:01 | | 3 | NESTED LOOPS SEMI | | 1 | 23 | 4 (0)| 00:00:01 | |- 4 | STATISTICS COLLECTOR | | | | | | | * 5 | TABLE ACCESS FULL | DEPARTMENTS | 1 | 16 | 3 (0)| 00:00:01 | | * 6 | TABLE ACCESS BY INDEX ROWID BATCHED| EMPLOYEES | 1 | 7 | 1 (0)| 00:00:01 | | * 7 | INDEX RANGE SCAN | EMP_DEPARTMENT_IX | 10 | | 0 (0)| 00:00:01 | |- * 8 | TABLE ACCESS FULL | EMPLOYEES | 1 | 7 | 1 (0)| 00:00:01 | --------------------------------------------------------------------------------------------------------------

Note ----- - this is an adaptive plan (rows marked '-' are inactive)

> STATISTICS COLLECTOR buffers the rows and able to switch to HASH JOIN when cardinality becomes

higher than what was estimated.

www.naya-tech.com | 5 Penn Plaza, 23rd floor Manhattan, New York 10001 +1.212.896.3945

Adaptive Execution Plans

www.naya-tech.com | 5 Penn Plaza, 23rd floor Manhattan, New York 10001 +1.212.896.3945

Adaptive Execution Plans

Rejected!

Accepted!

www.naya-tech.com | 5 Penn Plaza, 23rd floor Manhattan, New York 10001 +1.212.896.3945

Adaptive Execution Plans

www.naya-tech.com | 5 Penn Plaza, 23rd floor Manhattan, New York 10001 +1.212.896.3945

Enhanced Statistics> New histograms: Top, Hybrid.

> New Dynamic Sampling: Dynamic Sampled statistics (now

Dynamic Statistics) can be reused.

If defined at 2 (which is the default) dynamics statistics will be gathered if at leat one table in the query has no statistics.

If defined to 11 the database will use dynamic statistics  automatically when statistics are missing, statistics are stale,

statistics are insufficient.

www.naya-tech.com | 5 Penn Plaza, 23rd floor Manhattan, New York 10001 +1.212.896.3945

Enhanced Statistics

> Automatically compute statistics during loads (CATS).

www.naya-tech.com | 5 Penn Plaza, 23rd floor Manhattan, New York 10001 +1.212.896.3945

Data Optimisation and ILM > Oracle 12c creates “Heat Maps”

- tracks and marks data at the row and block level as it goes through life cycle changes.

> Automatic Data  Optimization  works with the

Heat Map feature and allows us to create policies.

> Automatic Data Optimization allows you to create policies for data compression and data

movement, to implement storage tiers.

www.naya-tech.com | 5 Penn Plaza, 23rd floor Manhattan, New York 10001 +1.212.896.3945

Data Optimisation and ILM

> Data can be:

Hot: the object is actively in Read/Write. Warm: the object which is accessed in

reads only Cold: the object is not participating in

any kind of activity.

www.naya-tech.com | 5 Penn Plaza, 23rd floor Manhattan, New York 10001 +1.212.896.3945

Data Optimisation and ILM

SQL> alter session set heat_map=on;

SQL> select * from scott.emp;

EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO ---------- ---------- --------- ---------- --------- ---------- ---------- ---------- 7369 SMITH CLERK 7902 17-DEC-80 800 20 7499 ALLEN SALESMAN 7698 20-FEB-81 1600

www.naya-tech.com | 5 Penn Plaza, 23rd floor Manhattan, New York 10001 +1.212.896.3945

Data Optimisation and ILM select object_name, track_time "Tracking Time", segment_write "Segment write", full_scan "Full Scan", lookup_scan "Lookup Scan" from DBA_HEAT_MAP_SEG_HISTOGRAM where object_name='MYOBJECTS' and owner = 'SCOTT';

OBJECT_NAME -------------------------------------------------------------------------------- Tracking Time Segment write Full Scan Lookup Scan ------------------ -------------- ------------ ------------ MYOBJECTS 09-sep-13 02:40:14 NO YES NO

www.naya-tech.com | 5 Penn Plaza, 23rd floor Manhattan, New York 10001 +1.212.896.3945

Data Optimisation and ILM

ALTER TABLE scott.myobjects ILM ADD POLICY ROW STORE COMPRESS ADVANCED SEGMENT AFTER 30 DAYS OF NO MODIFICATION;

www.naya-tech.com | 5 Penn Plaza, 23rd floor Manhattan, New York 10001 +1.212.896.3945

Row Pattern Matching

> An extension to the SELECT statement using MATCH_RECOGNIZE

that allows us to identify patterns across sequences of rows.

www.naya-tech.com | 5 Penn Plaza, 23rd floor Manhattan, New York 10001 +1.212.896.3945

Row Pattern Matching

PATTERN (STRT DOWN+ UP+)DEFINEDOWN AS DOWN.price < PREV(DOWN.price),UP AS UP.price > PREV(UP.price) 

XYZ 13-MAR-15 35 *********************************** XYZ 14-MAR-15 34 ********************************** XYZ 15-MAR-15 33 ********************************* XYZ 16-MAR-15 34 ********************************** XYZ 17-MAR-15 35 *********************************** XYZ 18-MAR-15 36 ************************************ XYZ 19-MAR-15 37 ************************************* XYZ 20-MAR-15 36 ************************************ XYZ 21-MAR-15 35 *********************************** XYZ 22-MAR-15 34 ********************************** XYZ 23-MAR-15 35 *********************************** XYZ 24-MAR-15 36 ************************************ XYZ 25-MAR-15 37 *************************************

Any record, followed by one or more records in which the price of the stock goes down, followed by one or more records in which the stock price increases.

www.naya-tech.com | 5 Penn Plaza, 23rd floor Manhattan, New York 10001 +1.212.896.3945

PL/SQL enhancements. > Define PL/SQL Subprograms in a

SQL Statement.

> Why would a developer want to copy logic from a PL/SQL function into a

SQL statement? To improve performance.

> No context switch to the PL/SQL engine.

www.naya-tech.com | 5 Penn Plaza, 23rd floor Manhattan, New York 10001 +1.212.896.3945

Pluggable Databases

A PDB is a self-contained, fully functional Oracle Database, and includes its own system, sysaux and user tablespaces.

www.naya-tech.com | 5 Penn Plaza, 23rd floor Manhattan, New York 10001 +1.212.896.3945

Pluggable Databases

> CDB: Similar to a conventional Oracle database.> Contains most of the working parts you will be already familiar with (controlfiles, datafiles, undo, tempfiles, redo logs etc.). > Contains the data dictionary for those objects that are owned by the root container and those that are visible to all PDBs.

www.naya-tech.com | 5 Penn Plaza, 23rd floor Manhattan, New York 10001 +1.212.896.3945

Pluggable Databases> PDB: Contains information specific to itself.

> Made up of datafiles and tempfiles to handle it's own objects: includes it's own data dictionary, containing information about only those objects that are specific to the PDB.

www.naya-tech.com | 5 Penn Plaza, 23rd floor Manhattan, New York 10001 +1.212.896.3945

Pluggable Databases

www.naya-tech.com | 5 Penn Plaza, 23rd floor Manhattan, New York 10001 +1.212.896.3945

Pluggable Databases

www.naya-tech.com | 5 Penn Plaza, 23rd floor Manhattan, New York 10001 +1.212.896.3945

Pluggable Databases> Allows databases to be moved easily> Allows quick patching and upgrading to future versions.

A PDB can be unplugged from a 12.1 CBD and plugged into a 12.2 CDB, effectively upgrading it in seconds.

www.naya-tech.com | 5 Penn Plaza, 23rd floor Manhattan, New York 10001 +1.212.896.3945

Pluggable Databases

12.1.0.2

Thank YouPlease visit us at www.naya-tech.com