Oracle Database 21c New Performance Features

Post on 20-May-2022

12 views 0 download

Transcript of Oracle Database 21c New Performance Features

oracle-performance.de

Oracle Database 21cNew Performance Features

Randolf Eberle-Geist

oracle-performance.de

oracle-performance.de

oracle-performance.de

• Independent consultant

• Performance Troubleshooting

• In-house workshops

• Cost-Based Optimizer

• Performance By Design

• Oracle ACE Director Alumni

• Member of OakTable Network

Oracle Database 21c New Performance Features2

2009-2016 Alumni

oracle-performance.de

Agenda

• 21c new performance features

• Previous versions noticeable performance features

Oracle Database 21c New Performance Features3

oracle-performance.de

21c New Performance Features

• SQL Macros (partially backported to 19c! (>= 19.6))

• Dynamic Sequence Cache (backported to 19c! (>= 19.10))

• Automatic SQL Tuning Set (ASTS) (backported to 19c! (>= 19.7))

• Automatic Zonemaps / Materialized Views (Exadata only)

=> Object Activity Tracking System (OATS)

• In Memory / Hash Join improvements

• Persistence Memory (PMEM) support

Oracle Database 21c New Performance Features4

oracle-performance.de

Previous versions noticeable performance features (1)

• Parallel Execution enhancements

• Attribute Clustering / Zonemaps (Zonemaps Exadata only)

• Database statistics enhancements (partially Exadata only)

• Approximate query / Top N processing

Oracle Database 21c New Performance Features5

oracle-performance.de

Previous versions noticeable performance features (2)

• PRAGMA UDF for PL/SQL functions called from SQL

• New built-in “always on” Index usage monitoring

• Private temporary tables

• Scalable Sequences

• Memoptimized read and write rowstore (Exadata only)

Oracle Database 21c New Performance Features6

oracle-performance.de

Previous versions noticeable performance features (3)

• Bitmap based COUNT(DISTINCT)

• SQL Quarantine (Exadata Only)

Oracle Database 21c New Performance Features7

oracle-performance.de

SQL Macros

• Advanced text replacement logic at parse time

• PL/SQL logic evaluated at parse time, returned string replaces macro expression in SQL and the resulting SQL string is parsed / evaluated by optimizer

• No execution of PL/SQL at runtime!

• Basic idea is reusability and encapsulation similar to PL/SQL functions but without the overhead and performance / optimizer implications

Oracle Database 21c New Performance Features8

oracle-performance.de

SQL Macros

• Two flavours: SCALAR (21c only) and TABLE (backported to 19c)

• TABLE Macros can only be used in the FROM clause

• SCALAR Macros everywhere else (projection, selection)

• Always defined as functions (with optional parameters) that return a string that will be put into the SQL in place of the SQL Macro

• The string returned can contain some replacement logic / “magic” based on the parameters passed into the SQL Macro

Oracle Database 21c New Performance Features9

oracle-performance.de

SQL Macros

DEMO!

Oracle Database 21c New Performance Features10

21c New Performance Features Scalar SQL Macros Demo.sql21c New Performance Features Table SQL Macros Demo.sql

oracle-performance.de

SQL Macros

• Basic promise is kept: Encapsulation and reusability without sacrifyingperformance – full visibility to optimizer

• Complex scenarios possible, in particular for TABLE SQL Macros using polymorphism

• But some noticeable limitations / counterintuitive behaviour in current releases

Oracle Database 21c New Performance Features11

oracle-performance.de

Dynamic Sequence Cache

• Any sequence defined with a CACHE size > 0 will get its cache size automatically dynamically resized at runtime if Oracle recognizes frequent usage of the sequence

• The CACHE_SIZE setting of the sequence isn’t updated

• The dynamic resize at runtime will adapt to the sequence usage

• It looks like sequences defined as NOCACHE don’t benefit from the feature

Oracle Database 21c New Performance Features12

oracle-performance.de

Dynamic Sequence Cache

DEMO!

Oracle Database 21c New Performance Features13

dynamic_sequence_cache_demo.sqldynamic_sequence_cache_demo2.sql

oracle-performance.de

Dynamic Sequence Cache

https://docs.oracle.com/en/database/oracle/oracle-database/21/nfcon/sequence-dynamic-cache-resizing-336399199.html

https://docs.oracle.com/en/database/oracle/oracle-database/21/admin/managing-views-sequences-and-synonyms.html#GUID-83FA2D7D-6119-4182-94EA-60554024A2CE

Oracle Database 21c New Performance Features14

oracle-performance.de

Automatic SQL Tuning Set (ASTS) 19.7+

• Introduced in RU 19.7 as backport, enabled by default

• Starting with RU 19.8 disabled by default

• Collects *all* plans for *all* queries seen – in contrast to AWR not only the top n “relevant” ones

• Automatic Indexing relies on it

• The idea is that plan regressions can be tackled more efficiently by identifying previously used good plans in the ASTS – automatic SQL plan management can do this automatically. With ASTS deactivated AWR might miss good executions that are not “relevant” enough during “good” times

Oracle Database 21c New Performance Features15

oracle-performance.de

Automatic SQL Tuning Set (ASTS) 19.7+-- View captured SQL statementsSelect sql_textfrom dba_sqlset_Statementswhere sqlset_name = 'SYS_AUTO_STS';

-- Enable / disable taskBegin

DBMS_Auto_Task_Admin.Enable(Client_Name => 'Auto STS Capture Task',Operation => NULL,Window_name => NULL);

End;/

BeginDBMS_Auto_Task_Admin.Disable(

Client_Name => 'Auto STS Capture Task',Operation => NULL,Window_name => NULL);

End;/

-- View task statusSelect Task_Name, EnabledFrom DBA_AutoTask_Schedule_ControlWhere Task_Name = 'Auto STS Capture Task';

Oracle Database 21c New Performance Features16

oracle-performance.de

Automatic SQL Tuning Set (ASTS) 19.7+

DEMO!

Oracle Database 21c New Performance Features17

automatic_sql_tuning_set_asts_demo.sql

oracle-performance.de

Parallel Execution Enhancements

• Various smaller enhancements since Oracle 12c

• Most of them aim for improving data distribution among Parallel Execution Servers: Hybrid hash / broadcast distribution (12c), Automatic skew handling (12c), Parallel Filter evaluation (12c) Null Random (18c), Adaptive PX BLOCK ITERATOR (19c)

• But the biggest threat still comes from additional BUFFEREDoperations in Parallel Execution plans due to internal implementation limitations

Oracle Database 21c New Performance Features18

oracle-performance.de

Parallel Execution Enhancements

• Either these are separate, additional BUFFER SORT operations

• Or the “famous” HASH JOIN BUFFERED – which means this operation has to “buffer” all surviving rows of the second row source to join –which is the (hopefully) larger one, and hence could mean significant additional work

• Oracle 18c has introduced the new “shared” HASH JOIN

• But even in 21c it’s not yet production ready

Oracle Database 21c New Performance Features19

oracle-performance.de

Parallel Execution Enhancements

• HASH JOIN SHARED is based on the new MGA (“Managed Global Area”) concept – a dynamically allocated, shared memory for a specific purpose and duration, in principle like “shared” PGA memory

• The Parallel Execution Server built each their hash table in MGA

• All Parallel Execution Servers share the “global” hash table during the probe phase

• Side effect: No specific re-distribution of data required!

Oracle Database 21c New Performance Features20

oracle-performance.de

Parallel Execution Enhancements

• SHARED HASH JOIN improves the Parallel Hash Join in two ways:

• No re-distribution overhead

• No need for HASH JOIN BUFFERED

• Should give many users of Parallel Execution a significant performance boost!

Oracle Database 21c New Performance Features21

oracle-performance.de

Parallel Execution Enhancements

DEMO!

Oracle Database 21c New Performance Features22

21c New Performance Features Parallel Execution enhancements.sql

oracle-performance.de

Parallel Execution Enhancements

https://chinaraliyev.wordpress.com/2019/04/29/parallel-shared-hash-join/

MGA (Managed Global Area) Reference Note (Doc ID 2638904.1)

Sizing the PGA in Oracle 19c - How to Account for the MGA Size (Doc ID 2808761.1)

Oracle Database 21c New Performance Features23

oracle-performance.de

Attribute Clustering

• Clustering data is one of the most underused and powerful performance features

• In previous releases only possible using specific non-heap table storage (Indexed / Hash Cluster / Index organized table (IOT)) or via manual implementation, so best suited for OLTP applications

• Non-heap table implementations do have some implications that need to be carefully considered (Cluster size, secondary indexes on IOTs etc.) and limited support for later features like partitioning, offloading in Exadata etc.

Oracle Database 21c New Performance Features24

oracle-performance.de

Attribute Clustering

• Attribute Clustering enables clustering of data in heap organized tables, but only during specific Direct Path operations, like INSERT APPEND, Create Table As Select, ALTER TABLE MOVE, Direct Path Load etc.

• Suites best Data Warehouse environments where Indexed / Hash Cluster and IOTs are not useful due to the limited fast data load / partition / indexing options

• Covers advanced scenarios like join clustering and clustering on multiple columns individually

• Can be combined with Zonemaps (on Exadata only unfortunately) for improving performance even further

Oracle Database 21c New Performance Features25

oracle-performance.de

Attribute Clustering improves

• Index access patterns – table blocks for same index value are clustered together, improves index access performance and Buffer Cache efficiency (less table blocks need to be cached for access patterns optimized via clustering)

• Compression – table data holding the same values are clustered together, improved compression ratio, applies not only to Advanced Compression but Exadata Hybrid Columnar Compression (HCC) and InMemorycompression, too

• Exadata Storage Index usage / Zonemaps / InMemory pruning – table blocks / storage regions / InMemory Compression Units not holding the data searched for can be skipped

Oracle Database 21c New Performance Features26

oracle-performance.de

Index access with scattered data

1,000 rows => visit 1,000 table blocks: 1,000 * 5ms = 5 s

oracle-performance.de

Index access with clustered data

1,000 rows => visit 10 table blocks: 10 * 5ms = 50 ms

oracle-performance.de

Nested Loop join with scattered data

oracle-performance.de

Nested Loop join with clustered data

oracle-performance.de

Attribute Clustering Linear vs. Interleaved

• Two types available

• LINEAR ORDER: Straightforward ORDER by specified column(s)

=> Only useful when using columns in specified order

• INTERLEAVED ORDER: Complex function that allows clustering being beneficial even when individual columns are specified

=> Internally implemented using undocumented functions ORA_CLUSTERING / ORA_RAWCONCAT etc.

Oracle Database 21c New Performance Features31

oracle-performance.de

Attribute Clustering Linear vs. Interleaved

Oracle Database 21c New Performance Features32

oracle-performance.de

Attribute Clustering

DEMO!

Oracle Database 21c New Performance Features33

06_ac_only_simple_clustering.sql06a_ac_only_simple_clustering_interleaved.sql06_ac_only_join_clustering.sql06_ac_only_join_clustering_demo.sql

oracle-performance.de

Oracle Database 21cNew Performance Features

Thank you!

Q&A

oracle-performance.de

Automatic Zonemaps / Materialized Views (Exadata only)https://docs.oracle.com/en/database/oracle/oracle-database/21/nfcon/automatic-materialized-views-264164435.html

https://docs.oracle.com/en/database/oracle/oracle-database/21/tgdba/auto_material_views.html#GUID-4E9D8731-2AE2-459A-ACFB-03C44D2A1ADD

Oracle Database 21c New Performance Features35

oracle-performance.de

In Memory / Hash Join improvements

https://docs.oracle.com/en/database/oracle/oracle-database/21/inmem/optimizing-queries-with-join-groups.html#GUID-55F66F65-1568-4B53-B79E-F841B94659CA

Oracle Database 21c New Performance Features36

oracle-performance.de

Persistence Memory (PMEM) support

https://docs.oracle.com/en/database/oracle/oracle-database/21/nfcon/persistent-memory-database-258797846.html

https://docs.oracle.com/en/database/oracle/oracle-database/21/admin/using-PMEM-db-support.html#GUID-A7ACCD50-30BD-49D1-AC34-14F143D4CD6D

Oracle Database 21c New Performance Features37

oracle-performance.de

AskTOM Office Hours

https://asktom.oracle.com/pls/apex/f?p=100:500:::NO:RP,500::

Oracle Database 12c/18c/19c New Features38