Professional Documents
Culture Documents
Con8622 Oracle Optimizer What To Expect in 12c Part2 PDF
Con8622 Oracle Optimizer What To Expect in 12c Part2 PDF
Con8622 Oracle Optimizer What To Expect in 12c Part2 PDF
d. Insert Information Protection Policy Classification from Slide 12 of the corporate presentation template
Oracle Optimizer: What’s
New in Oracle Database 12c?
Maria Colgan
Master Product Manager
PART 2
3 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12 of the corporate presentation template
Adaptive Query Optimization
Adaptive Query
Optimization
Adaptive Plans
Join methods
Parallel distribution methods
Adaptive
Adaptive Statistics Adaptive Plans
Statistics
Discovered at compile time
Discovered at run time
Join Parallel At At run
Methods distribution compile time
Methods time
4 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12 of the corporate presentation template
Dynamic Statistics
5 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12 of the corporate presentation template
Dynamic Statistics
6 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12 of the corporate presentation template
Dynamic Statistics
SGA
SHARED DYNAMIC STATISTICS
Select *
Table cardinality estimate for prod_info
From product_information
Where list_price-min_price=29
5 Optimizer determines
plan using dynamic SHARED_POOL
And category_id not in (11,22)
statistics
And prod_name like ‘Smart%’; Cursor 0: Select * from product_information …
SQL statement
1 is submitted
4 Dynamic sampling
occurs on small number of
blocks from table
Resulting dynamic statistics
are stored in cache
2 Optimizer checks
for existing statistics
in data dictionary
DATA DICTIONARY
3 Statistics found but need to be
augmented due to complex predicates
7 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12 of the corporate presentation template
Dynamic Statistics
SGA
SHARED DYNAMIC STATISTICS
Select supplier_id, prod_name
Table cardinality estimate for prod_info
From product_information
Where list_price-min_price=29
10 Optimizer determines
plan using dynamic SHARED_POOL
And category_id not in (11,22)
statistics
And prod_name like ‘Smart%’; Cursor 0: Select supplier_id, prod_name …
Different SQL
6 statement is
9 Necessary Dynamic
statistics found in shared
submitted with
cache
same predicates
7 Optimizer checks
for existing statistics
in data dictionary
DATA DICTIONARY
8 Statistics found but need to be
augmented due to complex predicates
8 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12 of the corporate presentation template
Adaptive Statistics
Re-optimization
9 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12 of the corporate presentation template
Adaptive Statistics
Cardinality Feedback in 11g
10 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12 of the corporate presentation template
Cardinality Feedback In 11g
Initial execution of a
query is monitored
Example shows initial
plan is hash join between
sales and customers
Cardinality estimates 8X
off
11 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12 of the corporate presentation template
Cardinality Feedback In 11g
12 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12 of the corporate presentation template
Re-optimization
Cardinality Feedback Evolution
13 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12 of the corporate presentation template
Re-optimization – Indicator In V$SQL
14 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12 of the corporate presentation template
Adaptive Plans & Re-Optimization Working
Together
Adapt join method
example showed the join
change from nested
loops to hash join
But cursor is also marked
IS_REOPTIMIZABLE
Why?
15 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12 of the corporate presentation template
Adaptive Plans & Re-Optimization Working
Together
Adapt join method
example showed the join
change from nested
loops to hash join
But cursor is also marked
IS_REOPTIMIZABLE
Why?
Re-optimization will occur
on second execution
because cardinality
estimates off Initial Cardinality estimates are off
16 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12 of the corporate presentation template
Adaptive Plans & Re-Optimization Working
Together
On second execution
statement is re-parsed
using execution statistics
New child cursor created
with new plan
New plan changes the
join order
17 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12 of the corporate presentation template
Adaptive Statistics
SQL Plan Directives
18 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12 of the corporate presentation template
SQL Plan Directives
SGA
DIRECTIVE CACHE
Directive: Use DS for customers table
Select * when column city, country are used
FROM customers 2 Optimizer determines
SHARED_POOL
where state =‘CA’ plan
AND country=‘USA’;
Cursor 0: Select * from customers
…….. IS_REOPTIMIZABLE = Y
SQL statement
1 is submitted
3 During execution
cardinality estimate
discovered to be wrong
and directive created
Sysaux Tablespace
19 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12 of the corporate presentation template
SQL Plan Directives
SGA
DIRECTIVE CACHE
Directive: Use DS for customer table
when column city, country are used
Select *
FROM customers
5 Optimizer determines
new plan using SHARED_POOL
where state=‘CA’ execution statistics
AND country=‘USA’;
Cursor 0: Select * from customers …..
IS_REOPTIMIZABLE = Y
Same SQL Cursor 1: Select * from customers …..
4
statement is
6 This execution and IS_REOPTIMIZABLE = N
subsequent execution
submitted use child cursor 1
again
Sysaux Tablespace
Directives periodically
Extension Binds Stats Sqlid persisted to disk in the
sysaux tablespace
SQL Directives
SQL Directives
20 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12 of the corporate presentation template
SQL Plan Directives
SGA
DIRECTIVE CACHE
10Optimizer adds
7 New SQL
column group creation
statement is
for state & country
submitted on
columns to next statistics
customers table
gather on customer table
8 Optimizer Sysaux Tablespace
checks for
directives on Extension Binds Stats Sqlid
customers table
and finds one on SQL Directives
the columns state
and country
21 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12 of the corporate presentation template
SQL Plan Directives
22 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12 of the corporate presentation template
Monitoring SQL Plan Directives
23 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12 of the corporate presentation template
Monitoring SQL Plan Directives
24 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12 of the corporate presentation template
Extended Statistics Automatically Created From
SQL Plan Directives
SQL Plan Directive state
was “MISSING_STATS”
Indicates Oracle can
automatically gather
statistics to improve the
original mis-estimation
In this case a column
group on STATE and
COUNTRY will address
the problem
25 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12 of the corporate presentation template
SQL Plan Directives
Monitoring
26 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12 of the corporate presentation template
SQL Plan Directives No Longer Needed
27 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12 of the corporate presentation template
Adaptive Query Optimization
Adaptive Statistics
Discovered at compile time
Adaptive
Discovered at run time Adaptive Plans
Statistics
Controlled by
OPTIMIZER_ADAPTIVE_FEATURES
Join Parallel At At run
Methods distribution compile time
Methods time
28 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12 of the corporate presentation template
END OF PART 2
29 Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12 of the corporate presentation template