The document discusses the top 12 new features of Oracle 12c, including improved column defaults that allow identity columns, increased size limits for VARCHAR columns up to 32K, improved queries for top-N results using ROW LIMIT clauses, and adaptive execution plans that allow the optimizer to choose alternative execution plans based on statistics gathered during the first execution. Temporary undo segments are also introduced to avoid generating redo for temporary table operations.
1. The top 12 new features of Oracle 12c!
David Yahalom,
CTO, NAYA Technologies
www.naya-tech.com
Email:
davidy@naya-tech.co.il
2. 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!
3. 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));
4. 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
5. 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…
6. 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)
7. 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);
8. 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;
9. 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)
10. 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_id
from t
order by owner, object_name
OFFSET 5 ROWS FETCH NEXT 5 ROWS ONLY;
11. 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
12. 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
13. www.naya-tech.com | 5 Penn Plaza, 23rd floor Manhattan, New York 10001 +1.212.896.3945
Temporary UNDO
Temp TBS & Temporary Undo
Redo logs
Undo TBS
Bulk Load
Permanent tables
Operations on temporary tables will
no longer generate redo.
14. 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
15. www.naya-tech.com | 5 Penn Plaza, 23rd floor Manhattan, New York 10001 +1.212.896.3945
Temporary UNDO
alter session
set temp_undo_enabled = true;
update my_table set object_name =
lower(object_name);
87310 rows updated.
Statistics
———————————————————————————————
…
0 redo size
…
16. 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;
17. 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.
18. www.naya-tech.com | 5 Penn Plaza, 23rd floor Manhattan, New York 10001 +1.212.896.3945
Transaction Guard
> Without:
19. 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;");
20. www.naya-tech.com | 5 Penn Plaza, 23rd floor Manhattan, New York 10001 +1.212.896.3945
Transaction Guard
> With:
21. 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!
22. www.naya-tech.com | 5 Penn Plaza, 23rd floor Manhattan, New York 10001 +1.212.896.3945
Adaptive Execution Plans
23. 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.
24. www.naya-tech.com | 5 Penn Plaza, 23rd floor Manhattan, New York 10001 +1.212.896.3945
Adaptive Execution Plans
25. www.naya-tech.com | 5 Penn Plaza, 23rd floor Manhattan, New York 10001 +1.212.896.3945
Adaptive Execution Plans
Rejected!
Accepted!
26. www.naya-tech.com | 5 Penn Plaza, 23rd floor Manhattan, New York 10001 +1.212.896.3945
Adaptive Execution Plans
27. 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.
28. 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).
29. 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.
30. 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.
31. 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
…
32. 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
33. 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;
34. 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.
35. www.naya-tech.com | 5 Penn Plaza, 23rd floor Manhattan, New York 10001 +1.212.896.3945
Row Pattern Matching
PATTERN (STRT DOWN+ UP+)
DEFINE
DOWN 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.
36. 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.
37. 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.
38. 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.
39. 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.
40. www.naya-tech.com | 5 Penn Plaza, 23rd floor Manhattan, New York 10001 +1.212.896.3945
Pluggable Databases
41. www.naya-tech.com | 5 Penn Plaza, 23rd floor Manhattan, New York 10001 +1.212.896.3945
Pluggable Databases
42. 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.
43. www.naya-tech.com | 5 Penn Plaza, 23rd floor Manhattan, New York 10001 +1.212.896.3945
Pluggable Databases
12.1.0.2