SlideShare a Scribd company logo
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Taming the beast
The 12c Optimizer
Connor McDonald
1
Copyright © 2018, Oracle and/or its affiliates. All rights reserved.
Connor McDonald
Copyright © 2018, Oracle and/or its affiliates. All rights reserved.
3
Copyright © 2018, Oracle and/or its affiliates. All rights reserved.
4
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
Stuff
youtube bit.ly/youtube-connor
blog bit.ly/blog-connor
twitter bit.ly/twitter-connor
400+ posts mainly on database & development
250 technical videos, new uploads every week
rants and raves on tech and the world :-)
Copyright © 2018, Oracle and/or its affiliates. All rights reserved.
etc...
facebook bit.ly/facebook-connor
linkedin bit.ly/linkedin-connor
instagram bit.ly/instagram-connor
slideshare bit.ly/slideshare-connor
Copyright © 2018, Oracle and/or its affiliates. All rights reserved.
7https://asktom.oracle.com
Copyright © 2018, Oracle and/or its affiliates. All rights reserved.
https://asktom.oracle.com/officehours
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
150 hours free access so far
9
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
this session
10
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
3 things
11
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
12c optimizer …
better performance
12
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
12c optimizer …
worse performance
13
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
worse performance …
14
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
15
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
16
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
goal of the optimizer
17
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
simple
18
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
good execution plan
19
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
so how did we end up here ?
20
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
21
You will upgrade us to 12c
with its new optimizer
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
LOL !LOL !
22
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
LMAOLMAO!
23
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
That dude
is toast!
That dude
is toast!
24
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Is this why I don't
have a desk ?
25
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
lots of fear
26
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
lots of mis-information
27
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
only 2 issues
28
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
ISSUE #1
29
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
missing or poor statistics
30
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
cardinality mis-estimates
31
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
cardinality is everything
32
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
33
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
better stats
34
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
missing or poor statistics
35
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
1) better histograms
36
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
2015
37
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
38
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
39
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Histograms are so
awesome. See
how much they
make me smile !
40
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
41
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
No …
… honest :-)
42
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
the sucky part
43
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SQL> create table T
2 as select * from dba_objects;
Table created.
SQL> exec dbms_stats.gather_table_stats('','T');
PL/SQL procedure successfully completed.
44
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SQL> select COLUMN_NAME,NUM_DISTINCT,
2 ( select count(*)
3 from all_tab_histograms
4 where owner = a.owner
5 and table_name = a.table_name
6 and column_name = a.column_name )
7 from all_tab_cols a
8 where table_name = 'T'
9 order by column_id;
COLUMN_NAME NUM_DISTINCT HIST_CNT
------------------------------ ------------ ----------
OWNER 25 2
OBJECT_NAME 53000 2
SUBOBJECT_NAME 230 2
OBJECT_ID 90808 2 45
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
46
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
47
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SQL> select intcol#,equality_preds,
2 range_preds,timestamp
3 from sys.col_usage$
4 where obj# = (select object_id
5 from obj
6 where object_name = 'T' );
INTCOL# EQUALITY_PREDS RANGE_PREDS TIMESTAMP
---------- -------------- ----------- ---------
1 1 0 24-SEP-17
48
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SQL> exec dbms_stats.gather_table_stats('','T');
SQL> select COLUMN_NAME,NUM_DISTINCT,
2 ( select count(*)
3 from all_tab_histograms
4 where owner = a.owner
5 and table_name = a.table_name
6 and column_name = a.column_name )
7 from all_tab_cols a
8 where table_name = 'T'
9 order by column_id;
COLUMN_NAME NUM_DISTINCT HIST_CNT
------------------------------ ------------ ----------
OWNER 25 25
OBJECT_NAME 53000 2
SUBOBJECT_NAME 230 2
OBJECT_ID 90808 2
49
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
we don't know what your "app" is
50
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
still requires care
51
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
12c improvements
52
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SQL> select status, count(*)
2 from orders
3 group by status
4 order by 1;
STATUS COUNT(*)
-------------------- ----------
1-New 1000
2-Assigned 10
3-InProgress 4000
4-Processed 3
5-Shipped 800
6-Received 5000
7-Completed 15000
8-Archived 20000
53
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
skewed ...
54
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
... need histogram
55
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
11g
56
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SQL> begin
2 dbms_stats.gather_table_stats('','ORDERS',
3 method_opt=>'for all columns size 15');
4 end;
5 /
PL/SQL procedure successfully completed.
SQL> select histogram from USER_TAB_COL_STATISTICS
2 where table_name = 'ORDERS';
HISTOGRAM
---------------
FREQUENCY
57
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SQL> select
2 endpoint_number,
3 substr(
4 utl_raw.cast_to_varchar2(
5 hextoraw(to_char(endpoint_value,rpad('FM',65,'X')))),1,5),
6 endpoint_number -
7 nvl(lag(endpoint_number) over ( order by endpoint_number),0)
8 from user_histograms
9 where table_name = 'ORDERS'
10 order by 1;
ENDPOINT_NUMBER END_VAL FREQ
--------------- -------------------- ----------
1000 1-Nev 1000
1010 2-Ass 10
5010 3-InP 4000
5013 4-Pro 3
5813 5-Shi 800
10813 6-Rec 5000
25813 7-Com 15000
45813 8-Arc 20000
58
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SQL> select
2 endpoint_number,
3 substr(
4 utl_raw.cast_to_varchar2(
5 hextoraw(to_char(endpoint_value,rpad('FM',65,'X')))),1,5),
6 endpoint_number -
7 nvl(lag(endpoint_number) over ( order by endpoint_number),0)
8 from user_histograms
9 where table_name = 'ORDERS'
10 order by 1;
ENDPOINT_NUMBER END_VAL FREQ
--------------- -------------------- ----------
1000 1-Nev 1000
1010 2-Ass 10
5010 3-InP 4000
5013 4-Pro 3
5813 5-Shi 800
10813 6-Rec 5000
25813 7-Com 15000
45813 8-Arc 20000
59
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SQL> select
2 endpoint_number,
3 substr(
4 utl_raw.cast_to_varchar2(
5 hextoraw(to_char(endpoint_value,rpad('FM',65,'X')))),1,5),
6 endpoint_number -
7 nvl(lag(endpoint_number) over ( order by endpoint_number),0)
8 from user_histograms
9 where table_name = 'ORDERS'
10 order by 1;
ENDPOINT_NUMBER END_VAL FREQ
--------------- -------------------- ----------
1000 1-Nev 1000
1010 2-Ass 10
5010 3-InP 4000
5013 4-Pro 3
5813 5-Shi 800
10813 6-Rec 5000
25813 7-Com 15000
45813 8-Arc 20000
60
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SQL> select * from orders
2 where status = '5-Shipped';
----------------------------------------------------
| Id | Operation | Name | Rows | Bytes |
----------------------------------------------------
| 0 | SELECT STATEMENT | | 800 | 8800 |
|* 1 | TABLE ACCESS FULL| ORDERS | 800 | 8800 |
----------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter("STATUS"='5-Shipped')
61
true = 800
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
so far … so good
62
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
NDV > 254*
63
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SQL> begin
2 dbms_stats.gather_table_stats('','ORDERS',
3 method_opt=>'for all columns size 6');
4 end;
5 /
PL/SQL procedure successfully completed.
SQL> select histogram from USER_TAB_COL_STATISTICS
2 where table_name = 'ORDERS';
HISTOGRAM
---------------
HEIGHT BALANCED
64
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SQL> select
2 endpoint_number,
3 substr(
4 utl_raw.cast_to_varchar2(
5 hextoraw(to_char(endpoint_value,rpad('FM',65,'X')))),1,5),
6 endpoint_number -
7 nvl(lag(endpoint_number) over ( order by endpoint_number),0)
8 from user_histograms
9 where table_name = 'ORDERS'
10 order by 1;
ENDPOINT_NUMBER END_VAL BKTS
--------------- -------------------- ----------
0 1-Nev 0
1 6-Rec 1
3 7-Com 2
6 8-Arc 3
65
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
1-New
6-Received
7-Complete
8-Archived
8-Archived
8-Archived
7-Complete
66
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SQL> select * from orders
2 where status = '8-Archived';
----------------------------------------------------
| Id | Operation | Name | Rows | Bytes |
----------------------------------------------------
| 0 | SELECT STATEMENT | | 19089 | 205K|
|* 1 | TABLE ACCESS FULL| ORDERS | 19089 | 205K|
----------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter("STATUS"='8-Archived')
true = 20000
67
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SQL> select * from orders
2 where status = '7-Completed';
-----------------------------------------------------
| Id | Operation | Name | Rows | Bytes |
-----------------------------------------------------
| 0 | SELECT STATEMENT | | 15271 | 164K|
|* 1 | TABLE ACCESS FULL| ORDERS | 15271 | 164K|
-----------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter("STATUS"='7-Completed')
true = 10000
68
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
69
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
1-New
6-Received
7-Complete
8-Archived
8-Archived
8-Archived
7-Completetotal ~ 45,000 ~7000 per bucket 70
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
1-New
6-Received
7-Complete
8-Archived
8-Archived
8-Archived
7-Completetotal = 45,000 ~7000 per bucket 71
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SQL> select * from orders
2 where status = '2-Assigned';
----------------------------------------------------
| Id | Operation | Name | Rows | Bytes |
----------------------------------------------------
| 0 | SELECT STATEMENT | | 1273 | 14003 |
|* 1 | TABLE ACCESS FULL| ORDERS | 1273 | 14003 |
----------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter("STATUS"='2-Assigned')
true = 3
72
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
height balanced means ...
73
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
bucket spanning = dramas
74
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
bucket swallowing = dramas
75
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
11g
HEIGHT-BALANCED
FREQUENCY
76
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Footnote: 11g
FOR ALL COLUMNS SIZE 25AUTO
77
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
78
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SQL> begin
2 dbms_stats.gather_table_stats('','ORDERS',
3 method_opt=>'for all columns size 15');
4 end;
5 /
PL/SQL procedure successfully completed.
SQL> select histogram from USER_TAB_COL_STATISTICS
2 where table_name = 'ORDERS';
HISTOGRAM
---------------
FREQUENCY
79
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SQL> begin
2 dbms_stats.gather_table_stats('','ORDERS',
3 method_opt=>'for all columns size 6');
4 end;
5 /
PL/SQL procedure successfully completed.
SQL> select histogram from USER_TAB_COL_STATISTICS
2 where table_name = 'ORDERS';
HISTOGRAM
---------------
TOP-FREQUENCY
80
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SQL> select
2 endpoint_number,
3 substr(
4 utl_raw.cast_to_varchar2(
5 hextoraw(to_char(endpoint_value,rpad('FM',65,'X')))),1,5)
6 endpoint_number -
7 nvl(lag(endpoint_number) over ( order by endpoint_number),0)
8 from user_histograms
9 where table_name = 'ORDERS'
10 order by 1;
ENDPOINT_NUMBER END_VAL FREQ
--------------- -------------------- ----------
1000 1-Nev 1000
5000 3-InP 4000
5800 5-Shi 800
10800 6-Rec 5000
25800 7-Com 15000
45800 8-Arc 20000 81
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
1-New
6-Received
3-InProgress
5-Shipped
8-Archived
7-Completed
82
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
other values ?
83
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SQL> select num_rows
2 from user_tables
3 where table_name = 'ORDERS';
NUM_ROWS
----------
45813
SQL> select num_distinct
2 from user_tab_cols
3 where table_name = 'ORDERS';
NUM_DISTINCT
------------
8
FREQ
----------
800
1000
4000
5000
15000
20000
========
45800
( 45813 - 45800 ) / ( 8 - 6 ) =
84
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SQL> select * from orders
2 where status = '4-Processed';
-----------------------------------------------------
| Id | Operation | Name | Rows | Bytes |
-----------------------------------------------------
| 0 | SELECT STATEMENT | | 7 | 77 |
|* 1 | TABLE ACCESS FULL| ORDERS | 7 | 77 |
-----------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter("STATUS"='4-Processed')
85
true = 3
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
what defines "TOP"
% top values > ((bkt-1)/bkt)* num
eg 1000 rows/ 12 bucket
12 most frequent > 11/12 * 1000
~920 rows
86
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
what if TOP FREQ not possible ?
87
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SQL> insert into orders select '1-New'
2 from dual connect by level <= 9000;
SQL> insert into orders select '2-Assigned'
2 from dual connect by level <= 9500;
SQL> insert into orders select '3-InProgress'
2 from dual connect by level <= 6000;
SQL> insert into orders select '4-Processed'
2 from dual connect by level <= 9500;
SQL> insert into orders select '5-Shipped'
2 from dual connect by level <= 8800;
SQL> insert into orders select '6-Received'
2 from dual connect by level <= 4500;
88
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SQL> select status, count(*)
2 from orders
3 group by status
4 order by 1;
STATUS COUNT(*)
-------------------- ----------
1-New 10000
2-Assigned 9510
3-InProgress 10000
4-Processed 9503
5-Shipped 9600
6-Received 9500
7-Completed 15000
8-Archived 20000
89
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SQL> begin
2 dbms_stats.gather_table_stats('','ORDERS',
3 method_opt=>'for all columns size 6');
4 end;
5 /
PL/SQL procedure successfully completed.
SQL> select histogram from USER_TAB_COL_STATISTICS
2 where table_name = 'ORDERS';
HISTOGRAM
---------------
HYBRID
90
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SQL> select
2 endpoint_number,
3 substr(
4 utl_raw.cast_to_varchar2(
5 hextoraw(to_char(endpoint_value,rpad('FM',65,'X')))),1,5),
6 endpoint_number -
7 nvl(lag(endpoint_number) over ( order by endpoint_number),0),
8 endpoint_repeat_count
9 from user_histograms
10 where table_name = 'ORDERS'
11 order by 1;
ENDPOINT_NUMBER END_VAL FREQ ENDPOINT_REPEAT_COUNT
--------------- -------------------- ---------- ---------------------
590 1-Nev 590 590
1743 3-InP 1153 626
2314 4-Pro 571 571
2895 5-Shi 581 581
3449 6-Rec 554 554
5547 8-Arc 2098 1213 91
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
1-New
6-Received
3-InProgress
5-Shipped
8-Archived
4-Processed
ENDPOINT_NUMBER END_VAL FREQ ENDPOINT_REPEAT_COUNT
--------------- -------------------- ---------- ---------------------
590 1-Nev 590 590
1743 3-InP 1153 626
2314 4-Pro 571 571
2895 5-Shi 581 581
3449 6-Rec 554 554
5547 8-Arc 2098 1213
2-Assigned
590 1153 571 581 554 2098
7-Completed
92
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
8-Archived
END_VAL FREQ ENDPOINT_REPEAT_COUNT
---------------- -------- ---------------------
1-Nev 590 590
3-InP 1153 626
4-Pro 571 571
5-Shi 581 581
6-Rec 554 554
8-Arc 2098 1213
2098
7-Completed
"Bucket 8-Arc has 2098 occurrences...
1213 of them are the end value 8-Arc...
therefore 885 are > 6-Rec and < 8-Arc"
93
6-Received
554
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
no bucket spanning
94
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
key point
95
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
must use auto sample size
96
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
still need care
97
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
representative values
98
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
"today's hot deals"
99
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
gather statistics
SQL> select count(*)
2 from items
3 where type = 'HOT_DEAL'
COUNT(*)
----------
0
100
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
activate "deals of the day"
SQL> update items
2 set type = 'HOT_DEAL'
3 where ...
SQL> select count(*)
2 from items
3 where type = 'HOT_DEAL'
COUNT(*)
----------
14
101
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
biggest day of the year !
SQL> select min(discount)
2 from items
3 where type = 'HOT_DEAL'
4 and ...
where type = 'HOT_DEAL'
SQL> select free_shipping
2 from items
3 where hot_deal = 'Y'
4 and ...
SQL> select ...
2 from ...
SQL> select ...
2 from ...
SQL> select ...
2 from ...
SQL> select ...
2 from ...SQL> select ...
2 from ...
102
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
where type = 'HOT_DEAL'
103
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
104
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SQL> select type, count(*)
2 from items
3 group by type;
TYPE COUNT(*)
------ ----------
ORDERED 21353
ARCHIVED 4213
NORMAL 513234
SOLD 528291
HOT_DEAL 0
105
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
normally...
106
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
"ok... I got 1,000,000 total rows...
and 7 distinct values.
I got a frequency histogram...
There's 4 popular values,
adding up to 910,000
That's 3 values left to cover the rest
3 / ( 1,000,000 - 910,000) = density
... I'm done!"
107
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SINGLE TABLE ACCESS PATH
Single Table Cardinality Estimation for ITEMS[ITEMS]
SPD: Return code in qosdDSDirSetup: NOCTX, estType = TABLE
kkecdn: Single Table Predicate:"ITEMS"."TYPE"='HOT_DEAL'
Column (#2):
NewDensity:0.001974, OldDensity:0.000000 BktCnt:1067091.000000,
PopBktCnt:1067091.000000, PopValCnt:4, NDV:4
Column (#2): TYPE(VARCHAR2)
AvgLen: 7 NDV: 4 Nulls: 0 Density: 0.001974
Histogram: Freq #Bkts: 4 UncompBkts: 1067091 EndPtVals: 4
Using density:
0.001974 of col #2 as selectivity of pred having unreasonably low value
NDV / (1067091 - 1067091)"Aaggghhhh!"
108
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SQL> select * from items where type = 'HOT_DEAL';
----------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)|
----------------------------------------------------------------
| 0 | SELECT STATEMENT | | 2107 | 23177 | 672 (2)|
|* 1 | TABLE ACCESS FULL| ITEMS | 2107 | 23177 | 672 (2)|
----------------------------------------------------------------
TYPE COUNT(*)
------ ----------
ORDERED 21353
ARCHIVED 4213 * 50%
NORMAL 513234
SOLD 528291
109
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
representative values
... at the right time
110
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
2) extensions
111
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
11g
112
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
"extended" statistics
113
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
aka "column groups"
114
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
solve GIGO
115
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SQL> select *
2 from ADDRESS
3 where CITY = 'Bangalore'
4 and COUNTRY = 'Australia';
116
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
117
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
automatic column groups
118
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
12.2
119
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
expression tracking
120
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SQL> select s.item_id,
2 s.category,
3 p.prod_list_price - p.prod_min_price
4 from products p,
5 sales s
6 where ....;
SQL> select expression_text, evaluation_count, fixed_cost
2 from user_expression_statistics
2 where table_name = 'PRODUCTS';
EXPRESSION_TEXT EVALUATION_COUNT FIXED_COST
---------------------------------- ---------------- ----------
"PROD_LIST_PRICE"-"PROD_MIN_PRICE" 766 .000041667
121
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
missing or poor statistics
122
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
3) online gather
123
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
the old problem
124
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SQL> insert /*+ APPEND */ into MY_TABLE
2 select *
3 from MY_WHOPPING_GREAT_FAT_TABLE;MY_WHOPPING_GREAT_FAT_TABLE;
125
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
126
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
127
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
128
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
129
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
130
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SQL> insert /*+ APPEND */ into MY_TABLE
2 select *
3 from MY_WHOPPING_GREAT_FAT_TABLE
4 ...
7102984123 rows created.
Elapsed: 06:12:34.00
131
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
and then...
132
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SQL> select num_rows from user_tables
2 where table_name = 'MY_TABLE';
NUM_ROWS
----------
133
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
so ...
134
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SQL> begin
2 dbms_stats.gather_table_stats('',
3 tname=>'MY_TABLE'
4 ...
5 ...
6 end;
7 /
Elapsed: a bloody long time
135
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
136
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
on load
137
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SQL> create table T (
2 ...
3 ...
4 ... );
Table created.
SQL> select num_rows
2 from user_tables
3 where table_name = 'T';
NUM_ROWS
----------
SQL> insert /*+ APPEND */ into T
2 select * from dba_objects;
78876 rows created.
SQL> commit;
Commit complete.
SQL> select num_rows
2 from user_tables
3 where table_name = 'T';
NUM_ROWS
----------
78876 138
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
things to note
139
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
must be direct
insert /*+ APPEND */
create table as select
140
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SQL> insert into T select * from dba_objects;
78876 rows created.
SQL> commit;
SQL> select num_rows from user_tables
2 where table_name = 'T';
NUM_ROWS
----------
141
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
must be empty
142
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SQL> insert into T values (....)
1 row created.
SQL> insert /*+ APPEND */ into T select * from dba_objects;
78876 rows created.
SQL> commit;
SQL> select num_rows from user_tables
2 where table_name = 'T';
NUM_ROWS
----------
143
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
execution plan
144
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SQL> insert /*+ APPEND */ into T
2 select * from t_src;
------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)|
------------------------------------------------------------------------------
| 0 | INSERT STATEMENT | | 78877 | 9M| 428 (1)|
| 1 | LOAD AS SELECT | T | | | |
| 2 | OPTIMIZER STATISTICS GATHERING | | 78877 | 9M| 428 (1)|
| 3 | TABLE ACCESS FULL | T_SRC| 78877 | 9M| 428 (1)|
------------------------------------------------------------------------------
145
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SQL> select column_name, notes
2 from user_tab_col_statistics
3 where table_name = 'T';
COLUMN_NAME NOTES
------------------------------ -------------
OWNER STATS_ON_LOAD
OBJECT_NAME STATS_ON_LOAD
SUBOBJECT_NAME STATS_ON_LOAD
OBJECT_ID STATS_ON_LOAD
DATA_OBJECT_ID STATS_ON_LOAD
OBJECT_TYPE STATS_ON_LOAD
CREATED STATS_ON_LOAD
...
...
146
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
note: no histograms
147
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
3) session GTT
148
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
11g
149
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SQL> create global temporary table t ( x int, y int )
2 on commit preserve rows;
Table created.
SQL> insert into t
2 select rownum, rownum
3 from dual
4 connect by level <= 10000;
10000 rows created.
150
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SQL> exec dbms_stats.gather_table_stats('','T');
SQL> set autotrace traceonly explain
SQL> select * from t;
---------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)|
---------------------------------------------------------------
| 0 | SELECT STATEMENT | | 10000 | 80000 | 7 (0)|
| 1 | TABLE ACCESS FULL| T | 10000 | 80000 | 7 (0)|
---------------------------------------------------------------
151
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
looks great until ...
152
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SQL> connect scott/tiger
Connected.
SQL> select count(*) from t;
COUNT(*)
----------
0
SQL> set autotrace traceonly explain
SQL> select * from t;
---------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)|
---------------------------------------------------------------
| 0 | SELECT STATEMENT | | 10000 | 80000 | 7 (0)|
| 1 | TABLE ACCESS FULL| T | 10000 | 80000 | 7 (0)|
---------------------------------------------------------------
153
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
154
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SQL> create global temporary table t ( x int, y int )
2 on commit preserve rows;
Table created.
SQL> insert into t
2 select rownum, rownum
3 from dual
4 connect by level <= 10000;
10000 rows created.
155
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SQL> exec dbms_stats.gather_table_stats('','T');
SQL> set autotrace traceonly explain
SQL> select * from t;
---------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)|
---------------------------------------------------------------
| 0 | SELECT STATEMENT | | 10000 | 80000 | 7 (0)|
| 1 | TABLE ACCESS FULL| T | 10000 | 80000 | 7 (0)|
---------------------------------------------------------------
as before
156
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SQL> connect scott/tiger
Connected.
SQL> insert into t
2 select rownum, rownum
3 from dual
4 connect by level <= 50;
50 rows created.
SQL> exec dbms_stats.gather_table_stats('','T');
157
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SQL> set autotrace traceonly explain
SQL> select * from t;
---------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)|
---------------------------------------------------------------
| 0 | SELECT STATEMENT | | 50 | 300 | 2 (0)|
| 1 | TABLE ACCESS FULL| T | 50 | 300 | 2 (0)|
---------------------------------------------------------------
Note
-----
- Global temporary table session private statistics used
158
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
back to session 1
159
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SQL> set autotrace traceonly explain
SQL> select * from t;
---------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)|
---------------------------------------------------------------
| 0 | SELECT STATEMENT | | 10000 | 80000 | 7 (0)|
| 1 | TABLE ACCESS FULL| T | 10000 | 80000 | 7 (0)|
---------------------------------------------------------------
160
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
note: default = private
161
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
so far ...
162
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
missing or poor statistics
163
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
improved optimizer "inputs"
histograms
gather on load
private GTT
164
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
ISSUE #2
165
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
statistics needed = "∞"
166
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
learn ... as we go
167
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
learn ... from experiences
168
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Adaptive Query Optimization #1
169
learn as we go
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
"Find all of the products with
a unit price of 15 that we have
sold more than 1 unit"
170
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SQL> set autotrace traceonly explain
SQL> select ...
2 from order_iterms o,
3 product_info p
4 where o.unit_price = 15
5 and o.quantity > 1
6 and o.product_id = p.product_id
-----------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes |
-----------------------------------------------------------------
| 0 | SELECT STATEMENT | | 12 | 200 |
| 1 | NESTED LOOPS | | 12 | 200 |
| 2 | NESTED LOOPS | | 12 | 200 |
| 3 | TABLE ACCESS FULL | ORDER_ITEMS | 12 | 800 |
| 4 | INDEX UNIQUE SCAN | PRODUCT_PK | 1 | 40 |
| 5 | TABLE ACCESS BY ROWID | PRODUCT_INFO | 1 | 10 |
-----------------------------------------------------------------
171
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
172
what if there's 5000 ?
4 where o.unit_price = 15
5 and o.quantity > 1
6 and o.product_id = p.product_id
-----------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes |
-----------------------------------------------------------------
| 0 | SELECT STATEMENT | | 12 | 200 |
| 1 | NESTED LOOPS | | 12 | 200 |
| 2 | NESTED LOOPS | | 12 | 200 |
| 3 | TABLE ACCESS FULL | ORDER_ITEMS | 12 | 800 |
| 4 | INDEX UNIQUE SCAN | PRODUCT_PK | 1 | 40 |
| 5 | TABLE ACCESS BY ROWID | PRODUCT_INFO | 1 | 10 |
-----------------------------------------------------------------
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
the runtime plan ?
173
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SQL> select * from table(
2 dbms_xplan.display_cursor('...'));
--------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)|
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 2000 | 16000 | 7 (0)|
| 1 | HASH JOIN | | 2000 | 16000 | 7 (0)|
| 2 | TABLE ACCESS FULL | ORDER_ITEMS | 10000 | 80000 | 7 (0)|
| 3 | TABLE ACCESS FULL | PRODUCT_INFO | 10000 | 80000 | 7 (0)|
--------------------------------------------------------------------------
174
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SQL> desc V$SQL
Name Null? Type
----------------------------------------- -------- ----------------------------
SQL_TEXT VARCHAR2(1000)
SQL_FULLTEXT CLOB
SQL_ID VARCHAR2(13)
SHARABLE_MEM NUMBER
PERSISTENT_MEM NUMBER
...
IS_BIND_SENSITIVE VARCHAR2(1)
IS_BIND_AWARE VARCHAR2(1)
...
IS_REOPTIMIZABLE VARCHAR2(1)
IS_RESOLVED_ADAPTIVE_PLAN VARCHAR2(1)
...
SQL>
175
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
cool
176
"dodged a bullet"
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Adaptive Query Optimization #2
177
learn from experience
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SQL> select /*+ gather_plan_statistics */ ...
2 from order_iterms o,
3 product_info p
4 where o.sales_date > date '2017-01-01'
5 and o.amt > 50
6 and o.product_id = p.product_id
-------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows | A-Rows |
-------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 7500 | 250 |
| 1 | HASH JOIN | | 1 | 7500 | 250 |
| 2 | TABLE ACCESS FULL | ORDER_ITEMS | 1 | 7500 | 250 |
| 3 | TABLE ACCESS FULL | PRODUCT_INFO | 1 | 200 | 212 |
-------------------------------------------------------------------------
178
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SQL> desc V$SQL
Name Null? Type
----------------------------------------- -------- ----------------------------
SQL_TEXT VARCHAR2(1000)
SQL_FULLTEXT CLOB
SQL_ID VARCHAR2(13)
SHARABLE_MEM NUMBER
PERSISTENT_MEM NUMBER
...
IS_BIND_SENSITIVE VARCHAR2(1)
IS_BIND_AWARE VARCHAR2(1)
...
IS_REOPTIMIZABLE VARCHAR2(1)
IS_RESOLVED_ADAPTIVE_PLAN VARCHAR2(1)
...
SQL>
179
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SQL> select /*+ gather_plan_statistics */ ...
2 from order_iterms o,
3 product_info p
4 where o.sales_date > date '2017-01-01'
5 and o.amt > 50
6 and o.product_id = p.product_id
-------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows | A-Rows |
-------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 250 | 250 |
| 1 | HASH JOIN | | 1 | 250 | 250 |
| 2 | TABLE ACCESS FULL | ORDER_ITEMS | 1 | 250 | 250 |
| 3 | TABLE ACCESS FULL | PRODUCT_INFO | 1 | 212 | 212 |
-------------------------------------------------------------------------
Note:
- statistics feedback used for this statement
180
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
seems cool
181
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
we mightta got carried away :-(
182
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SQL> select
2 directive_id,
3 type,
4 reason
5 from DBA_SQL_PLAN_DIRECTIVES;
DIRECTIVE_ID TYPE REASON
---------------------- ----------------------- ------------------------------------
14774885086507357845 DYNAMIC_SAMPLING JOIN CARDINALITY MISESTIMATE
3814111798494124542 DYNAMIC_SAMPLING JOIN CARDINALITY MISESTIMATE
14157928931483804012 DYNAMIC_SAMPLING JOIN CARDINALITY MISESTIMATE
3273885094090423666 DYNAMIC_SAMPLING JOIN CARDINALITY MISESTIMATE
17607835686132426105 DYNAMIC_SAMPLING SINGLE TABLE CARDINALITY MISESTIMATE
28719982731298412 DYNAMIC_SAMPLING_RESULT SINGLE TABLE CARDINALITY MISESTIMATE
1591495495394657516 DYNAMIC_SAMPLING JOIN CARDINALITY MISESTIMATE
162577689324691883 DYNAMIC_SAMPLING JOIN CARDINALITY MISESTIMATE
13736133022354002565 DYNAMIC_SAMPLING JOIN CARDINALITY MISESTIMATE
7592221435558555884 DYNAMIC_SAMPLING SINGLE TABLE CARDINALITY MISESTIMATE
...
...
183
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SQL> select ...
2 from order_iterms o,
3 product_info p
4 where o.sales_date > date '2017-01-01'
5 and o.product_id = p.product_id
Note:
- 3 Sql Plan Directives used for this statement
184
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
same SQL ...
185
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
... different plans
186
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
... then more different plans
187
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
... then even more different plans
188
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
So ... this happens
189
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
upgrade to 12.1
190
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
new optimizations
191
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
new statistics
192
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
default = everything enabled
193
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
"the plans keep changing"
194
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
just one switch
195
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
196
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
options
197
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
optimizer_adaptive_features = false
198
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
optimizer_features_enable = 11.2.0.4
199
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
don't panic ... that's fine
endorsed
200
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
12.1 ... perhaps too aggressive
201
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
12.2 ... more control
202
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
12.2 ... more passive
203
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
TRUE FALSE 204
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
12.2 ... much better
205
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
12.1
patch 22652097
206
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
which brings us to ...
207
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
upgrade scenarios
208
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
there are only two
209
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
1) your system sucks :-)
210
upgrade to 12.2
explore full adaptive
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
2) your system is OK
211
how can I lower risk ?
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SQL Plan Baselines
212
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
apology #1
213
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
214
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
but ultimately ...
215
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
... just three things
216
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
try run stuff good
1
217
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
when it's running good …
2
218
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
… keep running it like that !
219
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
If there is something better
220
3
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
then tell me
221
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
222
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
223
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
baselines do exactly this !
224
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
rarely used
225
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
apology #2
226
evolve
accepted
repeatable
unaccepted
capture
signature
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
close to our goals
227
working good ? Keep it
found something better ? Tell me
found something worse ? Don’t use it
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
not new
228
11g
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
(quick) terminology
229
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
signature
230
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SQL> select sal
from emp
where empno = ...
SQL> select SAL
from EMP where EMPNO = ...
SQL> SELECT /* comment */ SAL FROM EMP
WHERE EMPNO = ...
etc
etc
231
signature
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
plan(s) for signature
232
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
233
SELECT A.DATA,
B.DATA
FROM TAB1 A, TAB2
WHERE B.TAB1_ID = A.ID
AND A.CODE = :1
-----------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes |
-----------------------------------------------------------------------
| 0 | SELECT STATEMENT | | | |
| 1 | NESTED LOOPS | | 25 | 425 |
| 2 | NESTED LOOPS | | 25 | 425 |
|* 3 | TABLE ACCESS FULL | TAB1 | 1 | 11 |
|* 4 | INDEX RANGE SCAN | TAB2_TAB1_FKI | 25 | |
| 5 | TABLE ACCESS BY INDEX ROWID| TAB2 | 25 | 150 |
-----------------------------------------------------------------------
select a.data, b.data
from tab1 a, tab2
where b.tab1_id = a.id
and a.code = :1
"capture" a baseline
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
234
SELECT A.DATA,
B.DATA
FROM TAB1 A, TAB2
WHERE B.TAB1_ID = A.ID
AND A.CODE = :1
-----------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes |
-----------------------------------------------------------------------
| 0 | SELECT STATEMENT | | | |
| 1 | NESTED LOOPS | | 25 | 425 |
| 2 | NESTED LOOPS | | 25 | 425 |
|* 3 | TABLE ACCESS FULL | TAB1 | 1 | 11 |
|* 4 | INDEX RANGE SCAN | TAB2_TAB1_FKI | 25 | |
| 5 | TABLE ACCESS BY INDEX ROWID| TAB2 | 25 | 150 |
-----------------------------------------------------------------------
------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes |
------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | | |
| * 1 | HASH JOIN | | 25 | 425 |
| * 5 | TABLE ACCESS FULL | TAB1 | 1 | 11 |
| 8 | TABLE ACCESS FULL | TAB2 | 25 | 150 |
------------------------------------------------------------------------
select a.data, b.data
from tab1 a, tab2
where b.tab1_id = a.id
and a.code = :1
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
when it's running good …
235
… keep running it like that !
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
236
SELECT A.DATA,
B.DATA
FROM TAB1 A, TAB2
WHERE B.TAB1_ID = A.ID
AND A.CODE = :1
-----------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes |
-----------------------------------------------------------------------
| 0 | SELECT STATEMENT | | | |
| 1 | NESTED LOOPS | | 25 | 425 |
| 2 | NESTED LOOPS | | 25 | 425 |
|* 3 | TABLE ACCESS FULL | TAB1 | 1 | 11 |
|* 4 | INDEX RANGE SCAN | TAB2_TAB1_FKI | 25 | |
| 5 | TABLE ACCESS BY INDEX ROWID| TAB2 | 25 | 150 |
-----------------------------------------------------------------------
------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes |
------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | | |
| * 1 | HASH JOIN | | 25 | 425 |
| * 5 | TABLE ACCESS FULL | TAB1 | 1 | 11 |
| 8 | TABLE ACCESS FULL | TAB2 | 25 | 150 |
------------------------------------------------------------------------
select a.data, b.data
from tab1 a, tab2
where b.tab1_id = a.id
and a.code = :1
but we saved this !
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
maybe it is better ?
237
------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes |
------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | | |
| * 1 | HASH JOIN | | 25 | 425 |
| * 5 | TABLE ACCESS FULL | TAB1 | 1 | 11 |
| 8 | TABLE ACCESS FULL | TAB2 | 25 | 150 |
------------------------------------------------------------------------
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
evolve a plan
238
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
DBMS_SPM.EVOLVE_SQL_PLAN_BASELINE
239
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
240
SELECT A.DATA,
B.DATA
FROM TAB1 A, TAB2
WHERE B.TAB1_ID = A.ID
AND A.CODE = :1
-----------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes |
-----------------------------------------------------------------------
| 0 | SELECT STATEMENT | | | |
| 1 | NESTED LOOPS | | 25 | 425 |
| 2 | NESTED LOOPS | | 25 | 425 |
|* 3 | TABLE ACCESS FULL | TAB1 | 1 | 11 |
|* 4 | INDEX RANGE SCAN | TAB2_TAB1_FKI | 25 | |
| 5 | TABLE ACCESS BY INDEX ROWID| TAB2 | 25 | 150 |
-----------------------------------------------------------------------
------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes |
------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | | |
| * 1 | HASH JOIN | | 25 | 425 |
| * 5 | TABLE ACCESS FULL | TAB1 | 1 | 11 |
| 8 | TABLE ACCESS FULL | TAB2 | 25 | 150 |
------------------------------------------------------------------------
select a.data, b.data
from tab1 a, tab2
where b.tab1_id = a.id
and a.code = :1
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
unless …
241
… that makes it bad or
there's something better
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
if only we had done ...
242
DBMS_SPM.I_LOVE_THIS_PLAN(sql_id)
DBMS_SPM. THIS_PLAN_SUCKS(sql_id)
DBMS_SPM. SWAP_THIS_PLAN_IN(sql_id)
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
so back to upgrade
243
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
2) your system is OK
244
how can I lower risk ?
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SQL> alter system set
2 optimizer_capture_sql_plan_baselines = true
245
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SQL> exec DBMS_SPM.PACK_STGTAB_BASELINE
(datapump)
SQL> exec DBMS_SPM.UNPACK_STGTAB_BASELINE
246
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
the same performance
247
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
248
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
wrap up
249
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
12c optimizer is better
250
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
12c optimizer is different
251
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
12.2+ preferred
252
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
12.1 ... backport
253
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
SPM is your friend
254
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
Thank you!
youtube bit.ly/youtube-connor
blog bit.ly/blog-connor
twitter bit.ly/twitter-connor
400+ posts mainly on database & development
250 technical videos, new uploads every week
rants and raves on tech and the world :-)

More Related Content

PPTX
Sangam 18 - The New Optimizer in Oracle 12c
Connor McDonald
 
PPTX
Melbourne Groundbreakers Tour - Hints and Tips
Connor McDonald
 
PDF
Hyderabad Mar 2019 - Database 18c / 19c
Connor McDonald
 
PDF
Latin America Tour 2019 - 18c and 19c featues
Connor McDonald
 
PDF
18c and 19c features for DBAs
Connor McDonald
 
PPTX
Perth APAC Groundbreakers tour - 18c features
Connor McDonald
 
PDF
AIOUG - Groundbreakers - Jul 2019 - 19 Troubleshooting Tips and Tricks for Da...
Sandesh Rao
 
PDF
What's new in oracle trace file analyzer 18.2.0
Sandesh Rao
 
Sangam 18 - The New Optimizer in Oracle 12c
Connor McDonald
 
Melbourne Groundbreakers Tour - Hints and Tips
Connor McDonald
 
Hyderabad Mar 2019 - Database 18c / 19c
Connor McDonald
 
Latin America Tour 2019 - 18c and 19c featues
Connor McDonald
 
18c and 19c features for DBAs
Connor McDonald
 
Perth APAC Groundbreakers tour - 18c features
Connor McDonald
 
AIOUG - Groundbreakers - Jul 2019 - 19 Troubleshooting Tips and Tricks for Da...
Sandesh Rao
 
What's new in oracle trace file analyzer 18.2.0
Sandesh Rao
 

What's hot (20)

PDF
LAD - GroundBreakers - Jul 2019 - Using Oracle Autonomous Health Framework to...
Sandesh Rao
 
PPTX
#dbhouseparty - Real World Problem Solving with SQL
Tammy Bednar
 
PDF
EXAchk for Exadata Presentation
Sandesh Rao
 
PDF
Whats new in oracle trace file analyzer 18.3.0
Gareth Chapman
 
PDF
AUSOUG - Introducing New AI Ops Innovations in Oracle 19c Autonomous Health F...
Sandesh Rao
 
PDF
Oracle Autonomous Health Service- For Protecting Your On-Premise Databases- F...
Sandesh Rao
 
PDF
ILOUG 2019 - 18c/19c features
Connor McDonald
 
PDF
TFA_Whats_New_in version 12.1.2.8.4
Sandesh Rao
 
PDF
AIOUG : ODEVCYathra 2018 - Oracle Autonomous Database What Every DBA should know
Sandesh Rao
 
PDF
How to Upgrade Hundreds or Thousands of Databases
Guatemala User Group
 
PDF
What's new in Oracle and Exachk version 18.4.0
Sandesh Rao
 
PDF
AIOUG-GroundBreakers-Jul 2019 - 19c RAC
Sandesh Rao
 
PDF
Exachk Customer Presentation
Sandesh Rao
 
PDF
ORAchk EXAchk what's new in 12.1.0.2.7
Sandesh Rao
 
PDF
Polymorphic Table Functions in SQL
Chris Saxon
 
PDF
15 Troubleshooting Tips and Tricks for database 21c - OGBEMEA KSAOUG
Sandesh Rao
 
PDF
AUSOUG - NZOUG - Groundbreakers - Jun 2019 - 19 Troubleshooting Tips and Tric...
Sandesh Rao
 
PDF
Oracle Open World 2018 / Code One : MySQL 8.0 High Availability with MySQL I...
Frederic Descamps
 
PDF
Step by Step instructions to install Cluster Domain deployment model
Anil Nair
 
PDF
MySQL User Group NL: MySQL 8.0 Document Store- NoSQL with all the benefits of...
Frederic Descamps
 
LAD - GroundBreakers - Jul 2019 - Using Oracle Autonomous Health Framework to...
Sandesh Rao
 
#dbhouseparty - Real World Problem Solving with SQL
Tammy Bednar
 
EXAchk for Exadata Presentation
Sandesh Rao
 
Whats new in oracle trace file analyzer 18.3.0
Gareth Chapman
 
AUSOUG - Introducing New AI Ops Innovations in Oracle 19c Autonomous Health F...
Sandesh Rao
 
Oracle Autonomous Health Service- For Protecting Your On-Premise Databases- F...
Sandesh Rao
 
ILOUG 2019 - 18c/19c features
Connor McDonald
 
TFA_Whats_New_in version 12.1.2.8.4
Sandesh Rao
 
AIOUG : ODEVCYathra 2018 - Oracle Autonomous Database What Every DBA should know
Sandesh Rao
 
How to Upgrade Hundreds or Thousands of Databases
Guatemala User Group
 
What's new in Oracle and Exachk version 18.4.0
Sandesh Rao
 
AIOUG-GroundBreakers-Jul 2019 - 19c RAC
Sandesh Rao
 
Exachk Customer Presentation
Sandesh Rao
 
ORAchk EXAchk what's new in 12.1.0.2.7
Sandesh Rao
 
Polymorphic Table Functions in SQL
Chris Saxon
 
15 Troubleshooting Tips and Tricks for database 21c - OGBEMEA KSAOUG
Sandesh Rao
 
AUSOUG - NZOUG - Groundbreakers - Jun 2019 - 19 Troubleshooting Tips and Tric...
Sandesh Rao
 
Oracle Open World 2018 / Code One : MySQL 8.0 High Availability with MySQL I...
Frederic Descamps
 
Step by Step instructions to install Cluster Domain deployment model
Anil Nair
 
MySQL User Group NL: MySQL 8.0 Document Store- NoSQL with all the benefits of...
Frederic Descamps
 
Ad

Similar to Melbourne Groundbreakers Tour - Upgrading without risk (20)

PPTX
Wellington APAC Groundbreakers tour - Upgrading to the 12c Optimizer
Connor McDonald
 
PDF
OG Yatra - upgrading to the new 12c+ optimizer
Connor McDonald
 
PPTX
Beginners guide to_optimizer
Maria Colgan
 
PPTX
Five_Things_You_Might_Not_Know_About_Oracle_Database_v2.pptx
Maria Colgan
 
PDF
Managing Statistics for Optimal Query Performance
Karen Morton
 
PPTX
Oracle Query Optimizer - An Introduction
adryanbub
 
PDF
Oracle statistics by example
Mauro Pagano
 
PDF
In Search of Plan Stability - Part 1
Enkitec
 
PPTX
Five more things about Oracle SQL and PLSQL
Connor McDonald
 
PPTX
OpenWorld 2018 - 20 years of hints and tips
Connor McDonald
 
PPTX
DB
Samchu Li
 
PDF
31063115_1679409488310Developer_Tuning_Tips_-_UTOUG_Mar_2023.pdf
TricantinoLopezPerez
 
PPT
Optimizer in oracle 11g by wwf from ebay COC
Louis liu
 
PDF
Indexes overview
aioughydchapter
 
PPTX
The Five Best Things To Happen To SQL
Connor McDonald
 
PPTX
5 Cool Things About SQL
Connor McDonald
 
PPTX
Embarcadero In Search of Plan Stability Part 1 Webinar Slides
Embarcadero Technologies
 
PDF
Databse & Technology 2 | Connor McDonald | Managing Optimiser Statistics - A ...
InSync2011
 
PDF
Hailey_Database_Performance_Made_Easy_through_Graphics.pdf
cookie1969
 
PPTX
Calamities with cardinalities
Randolf Geist
 
Wellington APAC Groundbreakers tour - Upgrading to the 12c Optimizer
Connor McDonald
 
OG Yatra - upgrading to the new 12c+ optimizer
Connor McDonald
 
Beginners guide to_optimizer
Maria Colgan
 
Five_Things_You_Might_Not_Know_About_Oracle_Database_v2.pptx
Maria Colgan
 
Managing Statistics for Optimal Query Performance
Karen Morton
 
Oracle Query Optimizer - An Introduction
adryanbub
 
Oracle statistics by example
Mauro Pagano
 
In Search of Plan Stability - Part 1
Enkitec
 
Five more things about Oracle SQL and PLSQL
Connor McDonald
 
OpenWorld 2018 - 20 years of hints and tips
Connor McDonald
 
31063115_1679409488310Developer_Tuning_Tips_-_UTOUG_Mar_2023.pdf
TricantinoLopezPerez
 
Optimizer in oracle 11g by wwf from ebay COC
Louis liu
 
Indexes overview
aioughydchapter
 
The Five Best Things To Happen To SQL
Connor McDonald
 
5 Cool Things About SQL
Connor McDonald
 
Embarcadero In Search of Plan Stability Part 1 Webinar Slides
Embarcadero Technologies
 
Databse & Technology 2 | Connor McDonald | Managing Optimiser Statistics - A ...
InSync2011
 
Hailey_Database_Performance_Made_Easy_through_Graphics.pdf
cookie1969
 
Calamities with cardinalities
Randolf Geist
 
Ad

More from Connor McDonald (20)

PDF
Flashback ITOUG
Connor McDonald
 
PDF
Sangam 19 - PLSQL still the coolest
Connor McDonald
 
PDF
Sangam 19 - Analytic SQL
Connor McDonald
 
PDF
UKOUG - 25 years of hints and tips
Connor McDonald
 
PDF
Sangam 19 - Successful Applications on Autonomous
Connor McDonald
 
PDF
Sangam 2019 - The Latest Features
Connor McDonald
 
PDF
UKOUG 2019 - SQL features
Connor McDonald
 
PDF
APEX tour 2019 - successful development with autonomous
Connor McDonald
 
PDF
APAC Groundbreakers 2019 - Perth/Melbourne
Connor McDonald
 
PDF
OOW19 - Flashback, not just for DBAs
Connor McDonald
 
PDF
OOW19 - Read consistency
Connor McDonald
 
PDF
OOW19 - Slower and less secure applications
Connor McDonald
 
PDF
OOW19 - Killing database sessions
Connor McDonald
 
PDF
OOW19 - Ten Amazing SQL features
Connor McDonald
 
PDF
Latin America tour 2019 - Flashback
Connor McDonald
 
PDF
Latin America Tour 2019 - 10 great sql features
Connor McDonald
 
PDF
Latin America Tour 2019 - pattern matching
Connor McDonald
 
PDF
Latin America Tour 2019 - slow data and sql processing
Connor McDonald
 
PDF
ANSI vs Oracle language
Connor McDonald
 
PDF
OG Yatra - 25 years of hints and tips
Connor McDonald
 
Flashback ITOUG
Connor McDonald
 
Sangam 19 - PLSQL still the coolest
Connor McDonald
 
Sangam 19 - Analytic SQL
Connor McDonald
 
UKOUG - 25 years of hints and tips
Connor McDonald
 
Sangam 19 - Successful Applications on Autonomous
Connor McDonald
 
Sangam 2019 - The Latest Features
Connor McDonald
 
UKOUG 2019 - SQL features
Connor McDonald
 
APEX tour 2019 - successful development with autonomous
Connor McDonald
 
APAC Groundbreakers 2019 - Perth/Melbourne
Connor McDonald
 
OOW19 - Flashback, not just for DBAs
Connor McDonald
 
OOW19 - Read consistency
Connor McDonald
 
OOW19 - Slower and less secure applications
Connor McDonald
 
OOW19 - Killing database sessions
Connor McDonald
 
OOW19 - Ten Amazing SQL features
Connor McDonald
 
Latin America tour 2019 - Flashback
Connor McDonald
 
Latin America Tour 2019 - 10 great sql features
Connor McDonald
 
Latin America Tour 2019 - pattern matching
Connor McDonald
 
Latin America Tour 2019 - slow data and sql processing
Connor McDonald
 
ANSI vs Oracle language
Connor McDonald
 
OG Yatra - 25 years of hints and tips
Connor McDonald
 

Recently uploaded (20)

PDF
The Evolution of KM Roles (Presented at Knowledge Summit Dublin 2025)
Enterprise Knowledge
 
PDF
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
PDF
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
PDF
Trying to figure out MCP by actually building an app from scratch with open s...
Julien SIMON
 
PPTX
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
PDF
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
 
PDF
Event Presentation Google Cloud Next Extended 2025
minhtrietgect
 
PDF
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
PDF
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
PDF
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PDF
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
PDF
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
PDF
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
PPTX
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
PPTX
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
PPTX
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
PDF
NewMind AI Weekly Chronicles - July'25 - Week IV
NewMind AI
 
PDF
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
 
PDF
Get More from Fiori Automation - What’s New, What Works, and What’s Next.pdf
Precisely
 
The Evolution of KM Roles (Presented at Knowledge Summit Dublin 2025)
Enterprise Knowledge
 
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
Trying to figure out MCP by actually building an app from scratch with open s...
Julien SIMON
 
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
 
Event Presentation Google Cloud Next Extended 2025
minhtrietgect
 
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
NewMind AI Weekly Chronicles - July'25 - Week IV
NewMind AI
 
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
 
Get More from Fiori Automation - What’s New, What Works, and What’s Next.pdf
Precisely
 

Melbourne Groundbreakers Tour - Upgrading without risk

  • 1. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. Taming the beast The 12c Optimizer Connor McDonald 1
  • 2. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Connor McDonald
  • 3. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 3
  • 4. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 4
  • 5. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | Stuff youtube bit.ly/youtube-connor blog bit.ly/blog-connor twitter bit.ly/twitter-connor 400+ posts mainly on database & development 250 technical videos, new uploads every week rants and raves on tech and the world :-)
  • 6. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. etc... facebook bit.ly/facebook-connor linkedin bit.ly/linkedin-connor instagram bit.ly/instagram-connor slideshare bit.ly/slideshare-connor
  • 7. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. 7https://asktom.oracle.com
  • 8. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. https://asktom.oracle.com/officehours
  • 9. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 150 hours free access so far 9
  • 10. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. this session 10
  • 11. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 3 things 11
  • 12. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 12c optimizer … better performance 12
  • 13. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 12c optimizer … worse performance 13
  • 14. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. worse performance … 14
  • 15. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 15
  • 16. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 16
  • 17. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. goal of the optimizer 17
  • 18. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. simple 18
  • 19. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. good execution plan 19
  • 20. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. so how did we end up here ? 20
  • 21. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 21 You will upgrade us to 12c with its new optimizer
  • 22. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. LOL !LOL ! 22
  • 23. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. LMAOLMAO! 23
  • 24. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. That dude is toast! That dude is toast! 24
  • 25. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. Is this why I don't have a desk ? 25
  • 26. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. lots of fear 26
  • 27. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. lots of mis-information 27
  • 28. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. only 2 issues 28
  • 29. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. ISSUE #1 29
  • 30. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. missing or poor statistics 30
  • 31. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. cardinality mis-estimates 31
  • 32. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. cardinality is everything 32
  • 33. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 33
  • 34. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. better stats 34
  • 35. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. missing or poor statistics 35
  • 36. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 1) better histograms 36
  • 37. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 2015 37
  • 38. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 38
  • 39. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 39
  • 40. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. Histograms are so awesome. See how much they make me smile ! 40
  • 41. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 41
  • 42. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. No … … honest :-) 42
  • 43. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. the sucky part 43
  • 44. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. SQL> create table T 2 as select * from dba_objects; Table created. SQL> exec dbms_stats.gather_table_stats('','T'); PL/SQL procedure successfully completed. 44
  • 45. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. SQL> select COLUMN_NAME,NUM_DISTINCT, 2 ( select count(*) 3 from all_tab_histograms 4 where owner = a.owner 5 and table_name = a.table_name 6 and column_name = a.column_name ) 7 from all_tab_cols a 8 where table_name = 'T' 9 order by column_id; COLUMN_NAME NUM_DISTINCT HIST_CNT ------------------------------ ------------ ---------- OWNER 25 2 OBJECT_NAME 53000 2 SUBOBJECT_NAME 230 2 OBJECT_ID 90808 2 45
  • 46. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 46
  • 47. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 47
  • 48. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. SQL> select intcol#,equality_preds, 2 range_preds,timestamp 3 from sys.col_usage$ 4 where obj# = (select object_id 5 from obj 6 where object_name = 'T' ); INTCOL# EQUALITY_PREDS RANGE_PREDS TIMESTAMP ---------- -------------- ----------- --------- 1 1 0 24-SEP-17 48
  • 49. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. SQL> exec dbms_stats.gather_table_stats('','T'); SQL> select COLUMN_NAME,NUM_DISTINCT, 2 ( select count(*) 3 from all_tab_histograms 4 where owner = a.owner 5 and table_name = a.table_name 6 and column_name = a.column_name ) 7 from all_tab_cols a 8 where table_name = 'T' 9 order by column_id; COLUMN_NAME NUM_DISTINCT HIST_CNT ------------------------------ ------------ ---------- OWNER 25 25 OBJECT_NAME 53000 2 SUBOBJECT_NAME 230 2 OBJECT_ID 90808 2 49
  • 50. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. we don't know what your "app" is 50
  • 51. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. still requires care 51
  • 52. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 12c improvements 52
  • 53. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. SQL> select status, count(*) 2 from orders 3 group by status 4 order by 1; STATUS COUNT(*) -------------------- ---------- 1-New 1000 2-Assigned 10 3-InProgress 4000 4-Processed 3 5-Shipped 800 6-Received 5000 7-Completed 15000 8-Archived 20000 53
  • 54. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. skewed ... 54
  • 55. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. ... need histogram 55
  • 56. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 11g 56
  • 57. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. SQL> begin 2 dbms_stats.gather_table_stats('','ORDERS', 3 method_opt=>'for all columns size 15'); 4 end; 5 / PL/SQL procedure successfully completed. SQL> select histogram from USER_TAB_COL_STATISTICS 2 where table_name = 'ORDERS'; HISTOGRAM --------------- FREQUENCY 57
  • 58. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. SQL> select 2 endpoint_number, 3 substr( 4 utl_raw.cast_to_varchar2( 5 hextoraw(to_char(endpoint_value,rpad('FM',65,'X')))),1,5), 6 endpoint_number - 7 nvl(lag(endpoint_number) over ( order by endpoint_number),0) 8 from user_histograms 9 where table_name = 'ORDERS' 10 order by 1; ENDPOINT_NUMBER END_VAL FREQ --------------- -------------------- ---------- 1000 1-Nev 1000 1010 2-Ass 10 5010 3-InP 4000 5013 4-Pro 3 5813 5-Shi 800 10813 6-Rec 5000 25813 7-Com 15000 45813 8-Arc 20000 58
  • 59. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. SQL> select 2 endpoint_number, 3 substr( 4 utl_raw.cast_to_varchar2( 5 hextoraw(to_char(endpoint_value,rpad('FM',65,'X')))),1,5), 6 endpoint_number - 7 nvl(lag(endpoint_number) over ( order by endpoint_number),0) 8 from user_histograms 9 where table_name = 'ORDERS' 10 order by 1; ENDPOINT_NUMBER END_VAL FREQ --------------- -------------------- ---------- 1000 1-Nev 1000 1010 2-Ass 10 5010 3-InP 4000 5013 4-Pro 3 5813 5-Shi 800 10813 6-Rec 5000 25813 7-Com 15000 45813 8-Arc 20000 59
  • 60. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. SQL> select 2 endpoint_number, 3 substr( 4 utl_raw.cast_to_varchar2( 5 hextoraw(to_char(endpoint_value,rpad('FM',65,'X')))),1,5), 6 endpoint_number - 7 nvl(lag(endpoint_number) over ( order by endpoint_number),0) 8 from user_histograms 9 where table_name = 'ORDERS' 10 order by 1; ENDPOINT_NUMBER END_VAL FREQ --------------- -------------------- ---------- 1000 1-Nev 1000 1010 2-Ass 10 5010 3-InP 4000 5013 4-Pro 3 5813 5-Shi 800 10813 6-Rec 5000 25813 7-Com 15000 45813 8-Arc 20000 60
  • 61. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. SQL> select * from orders 2 where status = '5-Shipped'; ---------------------------------------------------- | Id | Operation | Name | Rows | Bytes | ---------------------------------------------------- | 0 | SELECT STATEMENT | | 800 | 8800 | |* 1 | TABLE ACCESS FULL| ORDERS | 800 | 8800 | ---------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 1 - filter("STATUS"='5-Shipped') 61 true = 800
  • 62. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. so far … so good 62
  • 63. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. NDV > 254* 63
  • 64. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. SQL> begin 2 dbms_stats.gather_table_stats('','ORDERS', 3 method_opt=>'for all columns size 6'); 4 end; 5 / PL/SQL procedure successfully completed. SQL> select histogram from USER_TAB_COL_STATISTICS 2 where table_name = 'ORDERS'; HISTOGRAM --------------- HEIGHT BALANCED 64
  • 65. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. SQL> select 2 endpoint_number, 3 substr( 4 utl_raw.cast_to_varchar2( 5 hextoraw(to_char(endpoint_value,rpad('FM',65,'X')))),1,5), 6 endpoint_number - 7 nvl(lag(endpoint_number) over ( order by endpoint_number),0) 8 from user_histograms 9 where table_name = 'ORDERS' 10 order by 1; ENDPOINT_NUMBER END_VAL BKTS --------------- -------------------- ---------- 0 1-Nev 0 1 6-Rec 1 3 7-Com 2 6 8-Arc 3 65
  • 66. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 1-New 6-Received 7-Complete 8-Archived 8-Archived 8-Archived 7-Complete 66
  • 67. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. SQL> select * from orders 2 where status = '8-Archived'; ---------------------------------------------------- | Id | Operation | Name | Rows | Bytes | ---------------------------------------------------- | 0 | SELECT STATEMENT | | 19089 | 205K| |* 1 | TABLE ACCESS FULL| ORDERS | 19089 | 205K| ---------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 1 - filter("STATUS"='8-Archived') true = 20000 67
  • 68. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. SQL> select * from orders 2 where status = '7-Completed'; ----------------------------------------------------- | Id | Operation | Name | Rows | Bytes | ----------------------------------------------------- | 0 | SELECT STATEMENT | | 15271 | 164K| |* 1 | TABLE ACCESS FULL| ORDERS | 15271 | 164K| ----------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 1 - filter("STATUS"='7-Completed') true = 10000 68
  • 69. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 69
  • 70. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 1-New 6-Received 7-Complete 8-Archived 8-Archived 8-Archived 7-Completetotal ~ 45,000 ~7000 per bucket 70
  • 71. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 1-New 6-Received 7-Complete 8-Archived 8-Archived 8-Archived 7-Completetotal = 45,000 ~7000 per bucket 71
  • 72. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. SQL> select * from orders 2 where status = '2-Assigned'; ---------------------------------------------------- | Id | Operation | Name | Rows | Bytes | ---------------------------------------------------- | 0 | SELECT STATEMENT | | 1273 | 14003 | |* 1 | TABLE ACCESS FULL| ORDERS | 1273 | 14003 | ---------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 1 - filter("STATUS"='2-Assigned') true = 3 72
  • 73. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. height balanced means ... 73
  • 74. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. bucket spanning = dramas 74
  • 75. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. bucket swallowing = dramas 75
  • 76. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 11g HEIGHT-BALANCED FREQUENCY 76
  • 77. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. Footnote: 11g FOR ALL COLUMNS SIZE 25AUTO 77
  • 78. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 78
  • 79. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. SQL> begin 2 dbms_stats.gather_table_stats('','ORDERS', 3 method_opt=>'for all columns size 15'); 4 end; 5 / PL/SQL procedure successfully completed. SQL> select histogram from USER_TAB_COL_STATISTICS 2 where table_name = 'ORDERS'; HISTOGRAM --------------- FREQUENCY 79
  • 80. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. SQL> begin 2 dbms_stats.gather_table_stats('','ORDERS', 3 method_opt=>'for all columns size 6'); 4 end; 5 / PL/SQL procedure successfully completed. SQL> select histogram from USER_TAB_COL_STATISTICS 2 where table_name = 'ORDERS'; HISTOGRAM --------------- TOP-FREQUENCY 80
  • 81. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. SQL> select 2 endpoint_number, 3 substr( 4 utl_raw.cast_to_varchar2( 5 hextoraw(to_char(endpoint_value,rpad('FM',65,'X')))),1,5) 6 endpoint_number - 7 nvl(lag(endpoint_number) over ( order by endpoint_number),0) 8 from user_histograms 9 where table_name = 'ORDERS' 10 order by 1; ENDPOINT_NUMBER END_VAL FREQ --------------- -------------------- ---------- 1000 1-Nev 1000 5000 3-InP 4000 5800 5-Shi 800 10800 6-Rec 5000 25800 7-Com 15000 45800 8-Arc 20000 81
  • 82. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 1-New 6-Received 3-InProgress 5-Shipped 8-Archived 7-Completed 82
  • 83. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. other values ? 83
  • 84. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. SQL> select num_rows 2 from user_tables 3 where table_name = 'ORDERS'; NUM_ROWS ---------- 45813 SQL> select num_distinct 2 from user_tab_cols 3 where table_name = 'ORDERS'; NUM_DISTINCT ------------ 8 FREQ ---------- 800 1000 4000 5000 15000 20000 ======== 45800 ( 45813 - 45800 ) / ( 8 - 6 ) = 84
  • 85. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. SQL> select * from orders 2 where status = '4-Processed'; ----------------------------------------------------- | Id | Operation | Name | Rows | Bytes | ----------------------------------------------------- | 0 | SELECT STATEMENT | | 7 | 77 | |* 1 | TABLE ACCESS FULL| ORDERS | 7 | 77 | ----------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 1 - filter("STATUS"='4-Processed') 85 true = 3
  • 86. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. what defines "TOP" % top values > ((bkt-1)/bkt)* num eg 1000 rows/ 12 bucket 12 most frequent > 11/12 * 1000 ~920 rows 86
  • 87. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. what if TOP FREQ not possible ? 87
  • 88. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. SQL> insert into orders select '1-New' 2 from dual connect by level <= 9000; SQL> insert into orders select '2-Assigned' 2 from dual connect by level <= 9500; SQL> insert into orders select '3-InProgress' 2 from dual connect by level <= 6000; SQL> insert into orders select '4-Processed' 2 from dual connect by level <= 9500; SQL> insert into orders select '5-Shipped' 2 from dual connect by level <= 8800; SQL> insert into orders select '6-Received' 2 from dual connect by level <= 4500; 88
  • 89. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. SQL> select status, count(*) 2 from orders 3 group by status 4 order by 1; STATUS COUNT(*) -------------------- ---------- 1-New 10000 2-Assigned 9510 3-InProgress 10000 4-Processed 9503 5-Shipped 9600 6-Received 9500 7-Completed 15000 8-Archived 20000 89
  • 90. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. SQL> begin 2 dbms_stats.gather_table_stats('','ORDERS', 3 method_opt=>'for all columns size 6'); 4 end; 5 / PL/SQL procedure successfully completed. SQL> select histogram from USER_TAB_COL_STATISTICS 2 where table_name = 'ORDERS'; HISTOGRAM --------------- HYBRID 90
  • 91. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. SQL> select 2 endpoint_number, 3 substr( 4 utl_raw.cast_to_varchar2( 5 hextoraw(to_char(endpoint_value,rpad('FM',65,'X')))),1,5), 6 endpoint_number - 7 nvl(lag(endpoint_number) over ( order by endpoint_number),0), 8 endpoint_repeat_count 9 from user_histograms 10 where table_name = 'ORDERS' 11 order by 1; ENDPOINT_NUMBER END_VAL FREQ ENDPOINT_REPEAT_COUNT --------------- -------------------- ---------- --------------------- 590 1-Nev 590 590 1743 3-InP 1153 626 2314 4-Pro 571 571 2895 5-Shi 581 581 3449 6-Rec 554 554 5547 8-Arc 2098 1213 91
  • 92. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 1-New 6-Received 3-InProgress 5-Shipped 8-Archived 4-Processed ENDPOINT_NUMBER END_VAL FREQ ENDPOINT_REPEAT_COUNT --------------- -------------------- ---------- --------------------- 590 1-Nev 590 590 1743 3-InP 1153 626 2314 4-Pro 571 571 2895 5-Shi 581 581 3449 6-Rec 554 554 5547 8-Arc 2098 1213 2-Assigned 590 1153 571 581 554 2098 7-Completed 92
  • 93. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 8-Archived END_VAL FREQ ENDPOINT_REPEAT_COUNT ---------------- -------- --------------------- 1-Nev 590 590 3-InP 1153 626 4-Pro 571 571 5-Shi 581 581 6-Rec 554 554 8-Arc 2098 1213 2098 7-Completed "Bucket 8-Arc has 2098 occurrences... 1213 of them are the end value 8-Arc... therefore 885 are > 6-Rec and < 8-Arc" 93 6-Received 554
  • 94. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. no bucket spanning 94
  • 95. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. key point 95
  • 96. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. must use auto sample size 96
  • 97. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. still need care 97
  • 98. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. representative values 98
  • 99. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. "today's hot deals" 99
  • 100. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. gather statistics SQL> select count(*) 2 from items 3 where type = 'HOT_DEAL' COUNT(*) ---------- 0 100
  • 101. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. activate "deals of the day" SQL> update items 2 set type = 'HOT_DEAL' 3 where ... SQL> select count(*) 2 from items 3 where type = 'HOT_DEAL' COUNT(*) ---------- 14 101
  • 102. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. biggest day of the year ! SQL> select min(discount) 2 from items 3 where type = 'HOT_DEAL' 4 and ... where type = 'HOT_DEAL' SQL> select free_shipping 2 from items 3 where hot_deal = 'Y' 4 and ... SQL> select ... 2 from ... SQL> select ... 2 from ... SQL> select ... 2 from ... SQL> select ... 2 from ...SQL> select ... 2 from ... 102
  • 103. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. where type = 'HOT_DEAL' 103
  • 104. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 104
  • 105. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. SQL> select type, count(*) 2 from items 3 group by type; TYPE COUNT(*) ------ ---------- ORDERED 21353 ARCHIVED 4213 NORMAL 513234 SOLD 528291 HOT_DEAL 0 105
  • 106. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. normally... 106
  • 107. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. "ok... I got 1,000,000 total rows... and 7 distinct values. I got a frequency histogram... There's 4 popular values, adding up to 910,000 That's 3 values left to cover the rest 3 / ( 1,000,000 - 910,000) = density ... I'm done!" 107
  • 108. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. SINGLE TABLE ACCESS PATH Single Table Cardinality Estimation for ITEMS[ITEMS] SPD: Return code in qosdDSDirSetup: NOCTX, estType = TABLE kkecdn: Single Table Predicate:"ITEMS"."TYPE"='HOT_DEAL' Column (#2): NewDensity:0.001974, OldDensity:0.000000 BktCnt:1067091.000000, PopBktCnt:1067091.000000, PopValCnt:4, NDV:4 Column (#2): TYPE(VARCHAR2) AvgLen: 7 NDV: 4 Nulls: 0 Density: 0.001974 Histogram: Freq #Bkts: 4 UncompBkts: 1067091 EndPtVals: 4 Using density: 0.001974 of col #2 as selectivity of pred having unreasonably low value NDV / (1067091 - 1067091)"Aaggghhhh!" 108
  • 109. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. SQL> select * from items where type = 'HOT_DEAL'; ---------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| ---------------------------------------------------------------- | 0 | SELECT STATEMENT | | 2107 | 23177 | 672 (2)| |* 1 | TABLE ACCESS FULL| ITEMS | 2107 | 23177 | 672 (2)| ---------------------------------------------------------------- TYPE COUNT(*) ------ ---------- ORDERED 21353 ARCHIVED 4213 * 50% NORMAL 513234 SOLD 528291 109
  • 110. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. representative values ... at the right time 110
  • 111. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 2) extensions 111
  • 112. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 11g 112
  • 113. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. "extended" statistics 113
  • 114. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. aka "column groups" 114
  • 115. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. solve GIGO 115
  • 116. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. SQL> select * 2 from ADDRESS 3 where CITY = 'Bangalore' 4 and COUNTRY = 'Australia'; 116
  • 117. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 117
  • 118. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. automatic column groups 118
  • 119. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 12.2 119
  • 120. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. expression tracking 120
  • 121. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. SQL> select s.item_id, 2 s.category, 3 p.prod_list_price - p.prod_min_price 4 from products p, 5 sales s 6 where ....; SQL> select expression_text, evaluation_count, fixed_cost 2 from user_expression_statistics 2 where table_name = 'PRODUCTS'; EXPRESSION_TEXT EVALUATION_COUNT FIXED_COST ---------------------------------- ---------------- ---------- "PROD_LIST_PRICE"-"PROD_MIN_PRICE" 766 .000041667 121
  • 122. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. missing or poor statistics 122
  • 123. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 3) online gather 123
  • 124. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. the old problem 124
  • 125. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. SQL> insert /*+ APPEND */ into MY_TABLE 2 select * 3 from MY_WHOPPING_GREAT_FAT_TABLE;MY_WHOPPING_GREAT_FAT_TABLE; 125
  • 126. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 126
  • 127. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 127
  • 128. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 128
  • 129. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 129
  • 130. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 130
  • 131. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. SQL> insert /*+ APPEND */ into MY_TABLE 2 select * 3 from MY_WHOPPING_GREAT_FAT_TABLE 4 ... 7102984123 rows created. Elapsed: 06:12:34.00 131
  • 132. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. and then... 132
  • 133. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. SQL> select num_rows from user_tables 2 where table_name = 'MY_TABLE'; NUM_ROWS ---------- 133
  • 134. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. so ... 134
  • 135. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. SQL> begin 2 dbms_stats.gather_table_stats('', 3 tname=>'MY_TABLE' 4 ... 5 ... 6 end; 7 / Elapsed: a bloody long time 135
  • 136. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 136
  • 137. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. on load 137
  • 138. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. SQL> create table T ( 2 ... 3 ... 4 ... ); Table created. SQL> select num_rows 2 from user_tables 3 where table_name = 'T'; NUM_ROWS ---------- SQL> insert /*+ APPEND */ into T 2 select * from dba_objects; 78876 rows created. SQL> commit; Commit complete. SQL> select num_rows 2 from user_tables 3 where table_name = 'T'; NUM_ROWS ---------- 78876 138
  • 139. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. things to note 139
  • 140. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. must be direct insert /*+ APPEND */ create table as select 140
  • 141. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. SQL> insert into T select * from dba_objects; 78876 rows created. SQL> commit; SQL> select num_rows from user_tables 2 where table_name = 'T'; NUM_ROWS ---------- 141
  • 142. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. must be empty 142
  • 143. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. SQL> insert into T values (....) 1 row created. SQL> insert /*+ APPEND */ into T select * from dba_objects; 78876 rows created. SQL> commit; SQL> select num_rows from user_tables 2 where table_name = 'T'; NUM_ROWS ---------- 143
  • 144. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. execution plan 144
  • 145. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. SQL> insert /*+ APPEND */ into T 2 select * from t_src; ------------------------------------------------------------------------------ | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| ------------------------------------------------------------------------------ | 0 | INSERT STATEMENT | | 78877 | 9M| 428 (1)| | 1 | LOAD AS SELECT | T | | | | | 2 | OPTIMIZER STATISTICS GATHERING | | 78877 | 9M| 428 (1)| | 3 | TABLE ACCESS FULL | T_SRC| 78877 | 9M| 428 (1)| ------------------------------------------------------------------------------ 145
  • 146. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. SQL> select column_name, notes 2 from user_tab_col_statistics 3 where table_name = 'T'; COLUMN_NAME NOTES ------------------------------ ------------- OWNER STATS_ON_LOAD OBJECT_NAME STATS_ON_LOAD SUBOBJECT_NAME STATS_ON_LOAD OBJECT_ID STATS_ON_LOAD DATA_OBJECT_ID STATS_ON_LOAD OBJECT_TYPE STATS_ON_LOAD CREATED STATS_ON_LOAD ... ... 146
  • 147. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. note: no histograms 147
  • 148. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 3) session GTT 148
  • 149. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 11g 149
  • 150. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. SQL> create global temporary table t ( x int, y int ) 2 on commit preserve rows; Table created. SQL> insert into t 2 select rownum, rownum 3 from dual 4 connect by level <= 10000; 10000 rows created. 150
  • 151. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. SQL> exec dbms_stats.gather_table_stats('','T'); SQL> set autotrace traceonly explain SQL> select * from t; --------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| --------------------------------------------------------------- | 0 | SELECT STATEMENT | | 10000 | 80000 | 7 (0)| | 1 | TABLE ACCESS FULL| T | 10000 | 80000 | 7 (0)| --------------------------------------------------------------- 151
  • 152. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. looks great until ... 152
  • 153. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. SQL> connect scott/tiger Connected. SQL> select count(*) from t; COUNT(*) ---------- 0 SQL> set autotrace traceonly explain SQL> select * from t; --------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| --------------------------------------------------------------- | 0 | SELECT STATEMENT | | 10000 | 80000 | 7 (0)| | 1 | TABLE ACCESS FULL| T | 10000 | 80000 | 7 (0)| --------------------------------------------------------------- 153
  • 154. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 154
  • 155. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. SQL> create global temporary table t ( x int, y int ) 2 on commit preserve rows; Table created. SQL> insert into t 2 select rownum, rownum 3 from dual 4 connect by level <= 10000; 10000 rows created. 155
  • 156. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. SQL> exec dbms_stats.gather_table_stats('','T'); SQL> set autotrace traceonly explain SQL> select * from t; --------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| --------------------------------------------------------------- | 0 | SELECT STATEMENT | | 10000 | 80000 | 7 (0)| | 1 | TABLE ACCESS FULL| T | 10000 | 80000 | 7 (0)| --------------------------------------------------------------- as before 156
  • 157. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. SQL> connect scott/tiger Connected. SQL> insert into t 2 select rownum, rownum 3 from dual 4 connect by level <= 50; 50 rows created. SQL> exec dbms_stats.gather_table_stats('','T'); 157
  • 158. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. SQL> set autotrace traceonly explain SQL> select * from t; --------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| --------------------------------------------------------------- | 0 | SELECT STATEMENT | | 50 | 300 | 2 (0)| | 1 | TABLE ACCESS FULL| T | 50 | 300 | 2 (0)| --------------------------------------------------------------- Note ----- - Global temporary table session private statistics used 158
  • 159. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. back to session 1 159
  • 160. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. SQL> set autotrace traceonly explain SQL> select * from t; --------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| --------------------------------------------------------------- | 0 | SELECT STATEMENT | | 10000 | 80000 | 7 (0)| | 1 | TABLE ACCESS FULL| T | 10000 | 80000 | 7 (0)| --------------------------------------------------------------- 160
  • 161. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. note: default = private 161
  • 162. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. so far ... 162
  • 163. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. missing or poor statistics 163
  • 164. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. improved optimizer "inputs" histograms gather on load private GTT 164
  • 165. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. ISSUE #2 165
  • 166. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. statistics needed = "∞" 166
  • 167. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. learn ... as we go 167
  • 168. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. learn ... from experiences 168
  • 169. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. Adaptive Query Optimization #1 169 learn as we go
  • 170. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. "Find all of the products with a unit price of 15 that we have sold more than 1 unit" 170
  • 171. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. SQL> set autotrace traceonly explain SQL> select ... 2 from order_iterms o, 3 product_info p 4 where o.unit_price = 15 5 and o.quantity > 1 6 and o.product_id = p.product_id ----------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | ----------------------------------------------------------------- | 0 | SELECT STATEMENT | | 12 | 200 | | 1 | NESTED LOOPS | | 12 | 200 | | 2 | NESTED LOOPS | | 12 | 200 | | 3 | TABLE ACCESS FULL | ORDER_ITEMS | 12 | 800 | | 4 | INDEX UNIQUE SCAN | PRODUCT_PK | 1 | 40 | | 5 | TABLE ACCESS BY ROWID | PRODUCT_INFO | 1 | 10 | ----------------------------------------------------------------- 171
  • 172. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 172 what if there's 5000 ? 4 where o.unit_price = 15 5 and o.quantity > 1 6 and o.product_id = p.product_id ----------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | ----------------------------------------------------------------- | 0 | SELECT STATEMENT | | 12 | 200 | | 1 | NESTED LOOPS | | 12 | 200 | | 2 | NESTED LOOPS | | 12 | 200 | | 3 | TABLE ACCESS FULL | ORDER_ITEMS | 12 | 800 | | 4 | INDEX UNIQUE SCAN | PRODUCT_PK | 1 | 40 | | 5 | TABLE ACCESS BY ROWID | PRODUCT_INFO | 1 | 10 | -----------------------------------------------------------------
  • 173. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. the runtime plan ? 173
  • 174. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. SQL> select * from table( 2 dbms_xplan.display_cursor('...')); -------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| -------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 2000 | 16000 | 7 (0)| | 1 | HASH JOIN | | 2000 | 16000 | 7 (0)| | 2 | TABLE ACCESS FULL | ORDER_ITEMS | 10000 | 80000 | 7 (0)| | 3 | TABLE ACCESS FULL | PRODUCT_INFO | 10000 | 80000 | 7 (0)| -------------------------------------------------------------------------- 174
  • 175. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. SQL> desc V$SQL Name Null? Type ----------------------------------------- -------- ---------------------------- SQL_TEXT VARCHAR2(1000) SQL_FULLTEXT CLOB SQL_ID VARCHAR2(13) SHARABLE_MEM NUMBER PERSISTENT_MEM NUMBER ... IS_BIND_SENSITIVE VARCHAR2(1) IS_BIND_AWARE VARCHAR2(1) ... IS_REOPTIMIZABLE VARCHAR2(1) IS_RESOLVED_ADAPTIVE_PLAN VARCHAR2(1) ... SQL> 175
  • 176. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. cool 176 "dodged a bullet"
  • 177. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. Adaptive Query Optimization #2 177 learn from experience
  • 178. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. SQL> select /*+ gather_plan_statistics */ ... 2 from order_iterms o, 3 product_info p 4 where o.sales_date > date '2017-01-01' 5 and o.amt > 50 6 and o.product_id = p.product_id ------------------------------------------------------------------------- | Id | Operation | Name | Starts | E-Rows | A-Rows | ------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | 7500 | 250 | | 1 | HASH JOIN | | 1 | 7500 | 250 | | 2 | TABLE ACCESS FULL | ORDER_ITEMS | 1 | 7500 | 250 | | 3 | TABLE ACCESS FULL | PRODUCT_INFO | 1 | 200 | 212 | ------------------------------------------------------------------------- 178
  • 179. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. SQL> desc V$SQL Name Null? Type ----------------------------------------- -------- ---------------------------- SQL_TEXT VARCHAR2(1000) SQL_FULLTEXT CLOB SQL_ID VARCHAR2(13) SHARABLE_MEM NUMBER PERSISTENT_MEM NUMBER ... IS_BIND_SENSITIVE VARCHAR2(1) IS_BIND_AWARE VARCHAR2(1) ... IS_REOPTIMIZABLE VARCHAR2(1) IS_RESOLVED_ADAPTIVE_PLAN VARCHAR2(1) ... SQL> 179
  • 180. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. SQL> select /*+ gather_plan_statistics */ ... 2 from order_iterms o, 3 product_info p 4 where o.sales_date > date '2017-01-01' 5 and o.amt > 50 6 and o.product_id = p.product_id ------------------------------------------------------------------------- | Id | Operation | Name | Starts | E-Rows | A-Rows | ------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | 250 | 250 | | 1 | HASH JOIN | | 1 | 250 | 250 | | 2 | TABLE ACCESS FULL | ORDER_ITEMS | 1 | 250 | 250 | | 3 | TABLE ACCESS FULL | PRODUCT_INFO | 1 | 212 | 212 | ------------------------------------------------------------------------- Note: - statistics feedback used for this statement 180
  • 181. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. seems cool 181
  • 182. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. we mightta got carried away :-( 182
  • 183. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. SQL> select 2 directive_id, 3 type, 4 reason 5 from DBA_SQL_PLAN_DIRECTIVES; DIRECTIVE_ID TYPE REASON ---------------------- ----------------------- ------------------------------------ 14774885086507357845 DYNAMIC_SAMPLING JOIN CARDINALITY MISESTIMATE 3814111798494124542 DYNAMIC_SAMPLING JOIN CARDINALITY MISESTIMATE 14157928931483804012 DYNAMIC_SAMPLING JOIN CARDINALITY MISESTIMATE 3273885094090423666 DYNAMIC_SAMPLING JOIN CARDINALITY MISESTIMATE 17607835686132426105 DYNAMIC_SAMPLING SINGLE TABLE CARDINALITY MISESTIMATE 28719982731298412 DYNAMIC_SAMPLING_RESULT SINGLE TABLE CARDINALITY MISESTIMATE 1591495495394657516 DYNAMIC_SAMPLING JOIN CARDINALITY MISESTIMATE 162577689324691883 DYNAMIC_SAMPLING JOIN CARDINALITY MISESTIMATE 13736133022354002565 DYNAMIC_SAMPLING JOIN CARDINALITY MISESTIMATE 7592221435558555884 DYNAMIC_SAMPLING SINGLE TABLE CARDINALITY MISESTIMATE ... ... 183
  • 184. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. SQL> select ... 2 from order_iterms o, 3 product_info p 4 where o.sales_date > date '2017-01-01' 5 and o.product_id = p.product_id Note: - 3 Sql Plan Directives used for this statement 184
  • 185. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. same SQL ... 185
  • 186. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. ... different plans 186
  • 187. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. ... then more different plans 187
  • 188. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. ... then even more different plans 188
  • 189. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. So ... this happens 189
  • 190. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. upgrade to 12.1 190
  • 191. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. new optimizations 191
  • 192. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. new statistics 192
  • 193. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. default = everything enabled 193
  • 194. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. "the plans keep changing" 194
  • 195. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. just one switch 195
  • 196. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 196
  • 197. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. options 197
  • 198. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. optimizer_adaptive_features = false 198
  • 199. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. optimizer_features_enable = 11.2.0.4 199
  • 200. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. don't panic ... that's fine endorsed 200
  • 201. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 12.1 ... perhaps too aggressive 201
  • 202. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 12.2 ... more control 202
  • 203. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 12.2 ... more passive 203
  • 204. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. TRUE FALSE 204
  • 205. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 12.2 ... much better 205
  • 206. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 12.1 patch 22652097 206
  • 207. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. which brings us to ... 207
  • 208. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. upgrade scenarios 208
  • 209. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. there are only two 209
  • 210. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 1) your system sucks :-) 210 upgrade to 12.2 explore full adaptive
  • 211. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 2) your system is OK 211 how can I lower risk ?
  • 212. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. SQL Plan Baselines 212
  • 213. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. apology #1 213
  • 214. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 214
  • 215. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. but ultimately ... 215
  • 216. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. ... just three things 216
  • 217. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. try run stuff good 1 217
  • 218. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. when it's running good … 2 218
  • 219. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. … keep running it like that ! 219
  • 220. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. If there is something better 220 3
  • 221. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. then tell me 221
  • 222. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 222
  • 223. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 223
  • 224. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. baselines do exactly this ! 224
  • 225. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. rarely used 225
  • 226. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. apology #2 226 evolve accepted repeatable unaccepted capture signature
  • 227. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. close to our goals 227 working good ? Keep it found something better ? Tell me found something worse ? Don’t use it
  • 228. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. not new 228 11g
  • 229. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. (quick) terminology 229
  • 230. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. signature 230
  • 231. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. SQL> select sal from emp where empno = ... SQL> select SAL from EMP where EMPNO = ... SQL> SELECT /* comment */ SAL FROM EMP WHERE EMPNO = ... etc etc 231 signature
  • 232. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. plan(s) for signature 232
  • 233. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 233 SELECT A.DATA, B.DATA FROM TAB1 A, TAB2 WHERE B.TAB1_ID = A.ID AND A.CODE = :1 ----------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | ----------------------------------------------------------------------- | 0 | SELECT STATEMENT | | | | | 1 | NESTED LOOPS | | 25 | 425 | | 2 | NESTED LOOPS | | 25 | 425 | |* 3 | TABLE ACCESS FULL | TAB1 | 1 | 11 | |* 4 | INDEX RANGE SCAN | TAB2_TAB1_FKI | 25 | | | 5 | TABLE ACCESS BY INDEX ROWID| TAB2 | 25 | 150 | ----------------------------------------------------------------------- select a.data, b.data from tab1 a, tab2 where b.tab1_id = a.id and a.code = :1 "capture" a baseline
  • 234. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 234 SELECT A.DATA, B.DATA FROM TAB1 A, TAB2 WHERE B.TAB1_ID = A.ID AND A.CODE = :1 ----------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | ----------------------------------------------------------------------- | 0 | SELECT STATEMENT | | | | | 1 | NESTED LOOPS | | 25 | 425 | | 2 | NESTED LOOPS | | 25 | 425 | |* 3 | TABLE ACCESS FULL | TAB1 | 1 | 11 | |* 4 | INDEX RANGE SCAN | TAB2_TAB1_FKI | 25 | | | 5 | TABLE ACCESS BY INDEX ROWID| TAB2 | 25 | 150 | ----------------------------------------------------------------------- ------------------------------------------------------------------------ | Id | Operation | Name | Rows | Bytes | ------------------------------------------------------------------------ | 0 | SELECT STATEMENT | | | | | * 1 | HASH JOIN | | 25 | 425 | | * 5 | TABLE ACCESS FULL | TAB1 | 1 | 11 | | 8 | TABLE ACCESS FULL | TAB2 | 25 | 150 | ------------------------------------------------------------------------ select a.data, b.data from tab1 a, tab2 where b.tab1_id = a.id and a.code = :1
  • 235. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. when it's running good … 235 … keep running it like that !
  • 236. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 236 SELECT A.DATA, B.DATA FROM TAB1 A, TAB2 WHERE B.TAB1_ID = A.ID AND A.CODE = :1 ----------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | ----------------------------------------------------------------------- | 0 | SELECT STATEMENT | | | | | 1 | NESTED LOOPS | | 25 | 425 | | 2 | NESTED LOOPS | | 25 | 425 | |* 3 | TABLE ACCESS FULL | TAB1 | 1 | 11 | |* 4 | INDEX RANGE SCAN | TAB2_TAB1_FKI | 25 | | | 5 | TABLE ACCESS BY INDEX ROWID| TAB2 | 25 | 150 | ----------------------------------------------------------------------- ------------------------------------------------------------------------ | Id | Operation | Name | Rows | Bytes | ------------------------------------------------------------------------ | 0 | SELECT STATEMENT | | | | | * 1 | HASH JOIN | | 25 | 425 | | * 5 | TABLE ACCESS FULL | TAB1 | 1 | 11 | | 8 | TABLE ACCESS FULL | TAB2 | 25 | 150 | ------------------------------------------------------------------------ select a.data, b.data from tab1 a, tab2 where b.tab1_id = a.id and a.code = :1 but we saved this !
  • 237. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. maybe it is better ? 237 ------------------------------------------------------------------------ | Id | Operation | Name | Rows | Bytes | ------------------------------------------------------------------------ | 0 | SELECT STATEMENT | | | | | * 1 | HASH JOIN | | 25 | 425 | | * 5 | TABLE ACCESS FULL | TAB1 | 1 | 11 | | 8 | TABLE ACCESS FULL | TAB2 | 25 | 150 | ------------------------------------------------------------------------
  • 238. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. evolve a plan 238
  • 239. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. DBMS_SPM.EVOLVE_SQL_PLAN_BASELINE 239
  • 240. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 240 SELECT A.DATA, B.DATA FROM TAB1 A, TAB2 WHERE B.TAB1_ID = A.ID AND A.CODE = :1 ----------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | ----------------------------------------------------------------------- | 0 | SELECT STATEMENT | | | | | 1 | NESTED LOOPS | | 25 | 425 | | 2 | NESTED LOOPS | | 25 | 425 | |* 3 | TABLE ACCESS FULL | TAB1 | 1 | 11 | |* 4 | INDEX RANGE SCAN | TAB2_TAB1_FKI | 25 | | | 5 | TABLE ACCESS BY INDEX ROWID| TAB2 | 25 | 150 | ----------------------------------------------------------------------- ------------------------------------------------------------------------ | Id | Operation | Name | Rows | Bytes | ------------------------------------------------------------------------ | 0 | SELECT STATEMENT | | | | | * 1 | HASH JOIN | | 25 | 425 | | * 5 | TABLE ACCESS FULL | TAB1 | 1 | 11 | | 8 | TABLE ACCESS FULL | TAB2 | 25 | 150 | ------------------------------------------------------------------------ select a.data, b.data from tab1 a, tab2 where b.tab1_id = a.id and a.code = :1
  • 241. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. unless … 241 … that makes it bad or there's something better
  • 242. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. if only we had done ... 242 DBMS_SPM.I_LOVE_THIS_PLAN(sql_id) DBMS_SPM. THIS_PLAN_SUCKS(sql_id) DBMS_SPM. SWAP_THIS_PLAN_IN(sql_id)
  • 243. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. so back to upgrade 243
  • 244. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 2) your system is OK 244 how can I lower risk ?
  • 245. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. SQL> alter system set 2 optimizer_capture_sql_plan_baselines = true 245
  • 246. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. SQL> exec DBMS_SPM.PACK_STGTAB_BASELINE (datapump) SQL> exec DBMS_SPM.UNPACK_STGTAB_BASELINE 246
  • 247. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. the same performance 247
  • 248. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 248
  • 249. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. wrap up 249
  • 250. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 12c optimizer is better 250
  • 251. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 12c optimizer is different 251
  • 252. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 12.2+ preferred 252
  • 253. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. 12.1 ... backport 253
  • 254. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. SPM is your friend 254
  • 255. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. Thank you! youtube bit.ly/youtube-connor blog bit.ly/blog-connor twitter bit.ly/twitter-connor 400+ posts mainly on database & development 250 technical videos, new uploads every week rants and raves on tech and the world :-)

Editor's Notes

  • #10: which of course means, we really should not be surprised when ask our customers about performance
  • #11: which of course means, we really should not be surprised when ask our customers about performance
  • #12: which of course means, we really should not be surprised when ask our customers about performance
  • #13: which of course means, we really should not be surprised when ask our customers about performance
  • #14: which of course means, we really should not be surprised when ask our customers about performance
  • #15: which of course means, we really should not be surprised when ask our customers about performance
  • #16: which of course means, we really should not be surprised when ask our customers about performance
  • #17: Where we all wish we were getting involved in the project … at the beginning
  • #18: which of course means, we really should not be surprised when ask our customers about performance
  • #19: which of course means, we really should not be surprised when ask our customers about performance
  • #20: which of course means, we really should not be surprised when ask our customers about performance
  • #21: which of course means, we really should not be surprised when ask our customers about performance
  • #22: So what happens when either the user hates us ? or gives us unachieveable goals ?
  • #23: So what happens when either the user hates us ? or gives us unachieveable goals ?
  • #24: So what happens when either the user hates us ? or gives us unachieveable goals ?
  • #25: So what happens when either the user hates us ? or gives us unachieveable goals ?
  • #26: So what happens when either the user hates us ? or gives us unachieveable goals ?
  • #27: which of course means, we really should not be surprised when ask our customers about performance
  • #28: which of course means, we really should not be surprised when ask our customers about performance
  • #29: which of course means, we really should not be surprised when ask our customers about performance
  • #30: Which is great…but is unrealistic.
  • #31: which of course means, we really should not be surprised when ask our customers about performance
  • #32: which of course means, we really should not be surprised when ask our customers about performance
  • #33: which of course means, we really should not be surprised when ask our customers about performance
  • #34: which of course means, we really should not be surprised when ask our customers about performance
  • #35: So what I'm thinking is we would touch just very briefly on the stuff in 12c that makes hopefully for better plans straight off the bat, so things like histograms, global temporary table stats
  • #36: which of course means, we really should not be surprised when ask our customers about performance
  • #37: So what I'm thinking is we would touch just very briefly on the stuff in 12c that makes hopefully for better plans straight off the bat, so things like histograms, global temporary table stats
  • #38: And the second thing about running a statement well is that even with the best statistics we might still have to make some adjustments and it is best to make those adjustments midstream than waiting for the statement to finish and putting the customer through all of that pain and only then being able to make adjustments on subsequent executions
  • #41: And the second thing about running a statement well is that even with the best statistics we might still have to make some adjustments and it is best to make those adjustments midstream than waiting for the statement to finish and putting the customer through all of that pain and only then being able to make adjustments on subsequent executions
  • #95: So to achieve our of goals - run fast - but keep an eye on how to run things faster - then either tell me or do it for me when needed we need something better… And its not something "NEW" in 18c, or 12c, …. Its something you already have !!!
  • #96: So to achieve our of goals - run fast - but keep an eye on how to run things faster - then either tell me or do it for me when needed we need something better… And its not something "NEW" in 18c, or 12c, …. Its something you already have !!!
  • #97: So to achieve our of goals - run fast - but keep an eye on how to run things faster - then either tell me or do it for me when needed we need something better… And its not something "NEW" in 18c, or 12c, …. Its something you already have !!!
  • #98: So to achieve our of goals - run fast - but keep an eye on how to run things faster - then either tell me or do it for me when needed we need something better… And its not something "NEW" in 18c, or 12c, …. Its something you already have !!!
  • #99: So to achieve our of goals - run fast - but keep an eye on how to run things faster - then either tell me or do it for me when needed we need something better… And its not something "NEW" in 18c, or 12c, …. Its something you already have !!!
  • #100: So to achieve our of goals - run fast - but keep an eye on how to run things faster - then either tell me or do it for me when needed we need something better… And its not something "NEW" in 18c, or 12c, …. Its something you already have !!!
  • #101: So to achieve our of goals - run fast - but keep an eye on how to run things faster - then either tell me or do it for me when needed we need something better… And its not something "NEW" in 18c, or 12c, …. Its something you already have !!!
  • #102: So to achieve our of goals - run fast - but keep an eye on how to run things faster - then either tell me or do it for me when needed we need something better… And its not something "NEW" in 18c, or 12c, …. Its something you already have !!!
  • #103: So to achieve our of goals - run fast - but keep an eye on how to run things faster - then either tell me or do it for me when needed we need something better… And its not something "NEW" in 18c, or 12c, …. Its something you already have !!!
  • #104: So to achieve our of goals - run fast - but keep an eye on how to run things faster - then either tell me or do it for me when needed we need something better… And its not something "NEW" in 18c, or 12c, …. Its something you already have !!!
  • #106: So to achieve our of goals - run fast - but keep an eye on how to run things faster - then either tell me or do it for me when needed we need something better… And its not something "NEW" in 18c, or 12c, …. Its something you already have !!!
  • #107: So to achieve our of goals - run fast - but keep an eye on how to run things faster - then either tell me or do it for me when needed we need something better… And its not something "NEW" in 18c, or 12c, …. Its something you already have !!!
  • #108: So to achieve our of goals - run fast - but keep an eye on how to run things faster - then either tell me or do it for me when needed we need something better… And its not something "NEW" in 18c, or 12c, …. Its something you already have !!!
  • #109: So to achieve our of goals - run fast - but keep an eye on how to run things faster - then either tell me or do it for me when needed we need something better… And its not something "NEW" in 18c, or 12c, …. Its something you already have !!!
  • #110: So to achieve our of goals - run fast - but keep an eye on how to run things faster - then either tell me or do it for me when needed we need something better… And its not something "NEW" in 18c, or 12c, …. Its something you already have !!!
  • #111: So to achieve our of goals - run fast - but keep an eye on how to run things faster - then either tell me or do it for me when needed we need something better… And its not something "NEW" in 18c, or 12c, …. Its something you already have !!!
  • #112: So to achieve our of goals - run fast - but keep an eye on how to run things faster - then either tell me or do it for me when needed we need something better… And its not something "NEW" in 18c, or 12c, …. Its something you already have !!!
  • #113: So to achieve our of goals - run fast - but keep an eye on how to run things faster - then either tell me or do it for me when needed we need something better… And its not something "NEW" in 18c, or 12c, …. Its something you already have !!!
  • #114: So to achieve our of goals - run fast - but keep an eye on how to run things faster - then either tell me or do it for me when needed we need something better… And its not something "NEW" in 18c, or 12c, …. Its something you already have !!!
  • #115: So to achieve our of goals - run fast - but keep an eye on how to run things faster - then either tell me or do it for me when needed we need something better… And its not something "NEW" in 18c, or 12c, …. Its something you already have !!!
  • #116: So to achieve our of goals - run fast - but keep an eye on how to run things faster - then either tell me or do it for me when needed we need something better… And its not something "NEW" in 18c, or 12c, …. Its something you already have !!!
  • #117: Because garbage in = garbage out no matter how good your optimiser is
  • #119: So to achieve our of goals - run fast - but keep an eye on how to run things faster - then either tell me or do it for me when needed we need something better… And its not something "NEW" in 18c, or 12c, …. Its something you already have !!!
  • #120: So to achieve our of goals - run fast - but keep an eye on how to run things faster - then either tell me or do it for me when needed we need something better… And its not something "NEW" in 18c, or 12c, …. Its something you already have !!!
  • #121: So to achieve our of goals - run fast - but keep an eye on how to run things faster - then either tell me or do it for me when needed we need something better… And its not something "NEW" in 18c, or 12c, …. Its something you already have !!!
  • #122: So to achieve our of goals - run fast - but keep an eye on how to run things faster - then either tell me or do it for me when needed we need something better… And its not something "NEW" in 18c, or 12c, …. Its something you already have !!!
  • #123: which of course means, we really should not be surprised when ask our customers about performance
  • #124: So to achieve our of goals - run fast - but keep an eye on how to run things faster - then either tell me or do it for me when needed we need something better… And its not something "NEW" in 18c, or 12c, …. Its something you already have !!!
  • #125: So to achieve our of goals - run fast - but keep an eye on how to run things faster - then either tell me or do it for me when needed we need something better… And its not something "NEW" in 18c, or 12c, …. Its something you already have !!!
  • #133: So to achieve our of goals - run fast - but keep an eye on how to run things faster - then either tell me or do it for me when needed we need something better… And its not something "NEW" in 18c, or 12c, …. Its something you already have !!!
  • #135: So to achieve our of goals - run fast - but keep an eye on how to run things faster - then either tell me or do it for me when needed we need something better… And its not something "NEW" in 18c, or 12c, …. Its something you already have !!!
  • #138: So to achieve our of goals - run fast - but keep an eye on how to run things faster - then either tell me or do it for me when needed we need something better… And its not something "NEW" in 18c, or 12c, …. Its something you already have !!!
  • #140: So to achieve our of goals - run fast - but keep an eye on how to run things faster - then either tell me or do it for me when needed we need something better… And its not something "NEW" in 18c, or 12c, …. Its something you already have !!!
  • #141: So to achieve our of goals - run fast - but keep an eye on how to run things faster - then either tell me or do it for me when needed we need something better… And its not something "NEW" in 18c, or 12c, …. Its something you already have !!!
  • #143: So to achieve our of goals - run fast - but keep an eye on how to run things faster - then either tell me or do it for me when needed we need something better… And its not something "NEW" in 18c, or 12c, …. Its something you already have !!!
  • #145: So to achieve our of goals - run fast - but keep an eye on how to run things faster - then either tell me or do it for me when needed we need something better… And its not something "NEW" in 18c, or 12c, …. Its something you already have !!!
  • #148: So to achieve our of goals - run fast - but keep an eye on how to run things faster - then either tell me or do it for me when needed we need something better… And its not something "NEW" in 18c, or 12c, …. Its something you already have !!!
  • #149: So to achieve our of goals - run fast - but keep an eye on how to run things faster - then either tell me or do it for me when needed we need something better… And its not something "NEW" in 18c, or 12c, …. Its something you already have !!!
  • #150: So to achieve our of goals - run fast - but keep an eye on how to run things faster - then either tell me or do it for me when needed we need something better… And its not something "NEW" in 18c, or 12c, …. Its something you already have !!!
  • #153: So to achieve our of goals - run fast - but keep an eye on how to run things faster - then either tell me or do it for me when needed we need something better… And its not something "NEW" in 18c, or 12c, …. Its something you already have !!!
  • #155: which of course means, we really should not be surprised when ask our customers about performance
  • #160: So to achieve our of goals - run fast - but keep an eye on how to run things faster - then either tell me or do it for me when needed we need something better… And its not something "NEW" in 18c, or 12c, …. Its something you already have !!!
  • #162: So to achieve our of goals - run fast - but keep an eye on how to run things faster - then either tell me or do it for me when needed we need something better… And its not something "NEW" in 18c, or 12c, …. Its something you already have !!!
  • #163: And the second thing about running a statement well is that even with the best statistics we might still have to make some adjustments and it is best to make those adjustments midstream than waiting for the statement to finish and putting the customer through all of that pain and only then being able to make adjustments on subsequent executions
  • #164: And the second thing about running a statement well is that even with the best statistics we might still have to make some adjustments and it is best to make those adjustments midstream than waiting for the statement to finish and putting the customer through all of that pain and only then being able to make adjustments on subsequent executions
  • #165: And the second thing about running a statement well is that even with the best statistics we might still have to make some adjustments and it is best to make those adjustments midstream than waiting for the statement to finish and putting the customer through all of that pain and only then being able to make adjustments on subsequent executions
  • #166: Which is great…but is unrealistic.
  • #167: which of course means, we really should not be surprised when ask our customers about performance
  • #168: And the second thing about running a statement well is that even with the best statistics we might still have to make some adjustments and it is best to make those adjustments midstream than waiting for the statement to finish and putting the customer through all of that pain and only then being able to make adjustments on subsequent executions
  • #169: And the second thing about running a statement well is that even with the best statistics we might still have to make some adjustments and it is best to make those adjustments midstream than waiting for the statement to finish and putting the customer through all of that pain and only then being able to make adjustments on subsequent executions
  • #170: And the second thing about running a statement well is that even with the best statistics we might still have to make some adjustments and it is best to make those adjustments midstream than waiting for the statement to finish and putting the customer through all of that pain and only then being able to make adjustments on subsequent executions
  • #174: And the second thing about running a statement well is that even with the best statistics we might still have to make some adjustments and it is best to make those adjustments midstream than waiting for the statement to finish and putting the customer through all of that pain and only then being able to make adjustments on subsequent executions
  • #177: And the second thing about running a statement well is that even with the best statistics we might still have to make some adjustments and it is best to make those adjustments midstream than waiting for the statement to finish and putting the customer through all of that pain and only then being able to make adjustments on subsequent executions
  • #178: And the second thing about running a statement well is that even with the best statistics we might still have to make some adjustments and it is best to make those adjustments midstream than waiting for the statement to finish and putting the customer through all of that pain and only then being able to make adjustments on subsequent executions
  • #182: And the second thing about running a statement well is that even with the best statistics we might still have to make some adjustments and it is best to make those adjustments midstream than waiting for the statement to finish and putting the customer through all of that pain and only then being able to make adjustments on subsequent executions
  • #183: And the second thing about running a statement well is that even with the best statistics we might still have to make some adjustments and it is best to make those adjustments midstream than waiting for the statement to finish and putting the customer through all of that pain and only then being able to make adjustments on subsequent executions
  • #186: And the second thing about running a statement well is that even with the best statistics we might still have to make some adjustments and it is best to make those adjustments midstream than waiting for the statement to finish and putting the customer through all of that pain and only then being able to make adjustments on subsequent executions
  • #187: And the second thing about running a statement well is that even with the best statistics we might still have to make some adjustments and it is best to make those adjustments midstream than waiting for the statement to finish and putting the customer through all of that pain and only then being able to make adjustments on subsequent executions
  • #188: And the second thing about running a statement well is that even with the best statistics we might still have to make some adjustments and it is best to make those adjustments midstream than waiting for the statement to finish and putting the customer through all of that pain and only then being able to make adjustments on subsequent executions
  • #189: And the second thing about running a statement well is that even with the best statistics we might still have to make some adjustments and it is best to make those adjustments midstream than waiting for the statement to finish and putting the customer through all of that pain and only then being able to make adjustments on subsequent executions
  • #190: So what happens when either the user hates us ? or gives us unachieveable goals ?
  • #191: So what happens when either the user hates us ? or gives us unachieveable goals ?
  • #192: So what happens when either the user hates us ? or gives us unachieveable goals ?
  • #193: So what happens when either the user hates us ? or gives us unachieveable goals ?
  • #194: So what happens when either the user hates us ? or gives us unachieveable goals ?
  • #196: So what happens when either the user hates us ? or gives us unachieveable goals ?
  • #198: So what happens when either the user hates us ? or gives us unachieveable goals ?
  • #201: So what happens when either the user hates us ? or gives us unachieveable goals ?
  • #202: So what happens when either the user hates us ? or gives us unachieveable goals ?
  • #203: So what happens when either the user hates us ? or gives us unachieveable goals ?
  • #204: So what happens when either the user hates us ? or gives us unachieveable goals ?
  • #206: So what happens when either the user hates us ? or gives us unachieveable goals ?
  • #207: So what happens when either the user hates us ? or gives us unachieveable goals ?
  • #208: But ultimately….from the optimizer we really want some simple things
  • #209: But ultimately….from the optimizer we really want some simple things
  • #210: But ultimately….from the optimizer we really want some simple things
  • #211: But ultimately….from the optimizer we really want some simple things
  • #212: But ultimately….from the optimizer we really want some simple things
  • #213: But ultimately….from the optimizer we really want some simple things
  • #214: So what happens when either the user hates us ? or gives us unachieveable goals ?
  • #215: We will concede that over a number a releases, we've introduced, enhanced, re-thought a LOT of things with regard to the optimizer.. … which can make things feel a little overwhelming.
  • #216: But ultimately….from the optimizer we really want some simple things
  • #217: But ultimately….from the optimizer we really want some simple things
  • #218: 1) run my SQL as good as it can be run … or at least TRY to
  • #219: 2) and when you've got it running good…
  • #220: for god sakes, don't change anything. Just keep running it good… all the time, exactly like it is today….
  • #221: "….but … I don’t want to look like a fool, so if you DO find something better…."
  • #222: then please tell me…
  • #223: BUT DON"T TOUCH ANYTHIING. Let *me* decide if this is a good switch to make.
  • #224: We will concede that over a number a releases, we've introduced, enhanced, re-thought a LOT of things with regard to the optimizer.. … which can make things feel a little overwhelming.
  • #225: then please tell me…
  • #226: So when it comes to running stuff well, the two elements we would focus on are - better statistics so the chances of getting a good plan are better - and a recognition that no matter how good the statistics are there will always be challenges for the optimizer so it needs the ability to change course mid-stride
  • #227: So what happens when either the user hates us ? or gives us unachieveable goals ?
  • #228: So when it comes to running stuff well, the two elements we would focus on are - better statistics so the chances of getting a good plan are better - and a recognition that no matter how good the statistics are there will always be challenges for the optimizer so it needs the ability to change course mid-stride
  • #229: So when it comes to running stuff well, the two elements we would focus on are - better statistics so the chances of getting a good plan are better - and a recognition that no matter how good the statistics are there will always be challenges for the optimizer so it needs the ability to change course mid-stride
  • #230: So when it comes to running stuff well, the two elements we would focus on are - better statistics so the chances of getting a good plan are better - and a recognition that no matter how good the statistics are there will always be challenges for the optimizer so it needs the ability to change course mid-stride
  • #231: So when it comes to running stuff well, the two elements we would focus on are - better statistics so the chances of getting a good plan are better - and a recognition that no matter how good the statistics are there will always be challenges for the optimizer so it needs the ability to change course mid-stride
  • #233: So when it comes to running stuff well, the two elements we would focus on are - better statistics so the chances of getting a good plan are better - and a recognition that no matter how good the statistics are there will always be challenges for the optimizer so it needs the ability to change course mid-stride
  • #234: These are just some slides I ripped out of existing decks, obviously they would be cleaned up and formatted as we see fit but really just to touch on some of the things in 12c whether it be release 1 or release 2
  • #235: These are just some slides I ripped out of existing decks, obviously they would be cleaned up and formatted as we see fit but really just to touch on some of the things in 12c whether it be release 1 or release 2
  • #236: 2) and when you've got it running good…
  • #237: These are just some slides I ripped out of existing decks, obviously they would be cleaned up and formatted as we see fit but really just to touch on some of the things in 12c whether it be release 1 or release 2
  • #238: for god sakes, don't change anything. Just keep running it good… all the time, exactly like it is today….
  • #239: for god sakes, don't change anything. Just keep running it good… all the time, exactly like it is today….
  • #241: These are just some slides I ripped out of existing decks, obviously they would be cleaned up and formatted as we see fit but really just to touch on some of the things in 12c whether it be release 1 or release 2
  • #242: and 3…. which is always the kicker … unless of course
  • #243: So when it comes to running stuff well, the two elements we would focus on are - better statistics so the chances of getting a good plan are better - and a recognition that no matter how good the statistics are there will always be challenges for the optimizer so it needs the ability to change course mid-stride
  • #244: And the second thing about running a statement well is that even with the best statistics we might still have to make some adjustments and it is best to make those adjustments midstream than waiting for the statement to finish and putting the customer through all of that pain and only then being able to make adjustments on subsequent executions
  • #245: But ultimately….from the optimizer we really want some simple things
  • #248: And the second thing about running a statement well is that even with the best statistics we might still have to make some adjustments and it is best to make those adjustments midstream than waiting for the statement to finish and putting the customer through all of that pain and only then being able to make adjustments on subsequent executions
  • #249: which of course means, we really should not be surprised when ask our customers about performance
  • #250: So to achieve our of goals - run fast - but keep an eye on how to run things faster - then either tell me or do it for me when needed we need something better… And its not something "NEW" in 18c, or 12c, …. Its something you already have !!!
  • #251: So to achieve our of goals - run fast - but keep an eye on how to run things faster - then either tell me or do it for me when needed we need something better… And its not something "NEW" in 18c, or 12c, …. Its something you already have !!!
  • #252: So to achieve our of goals - run fast - but keep an eye on how to run things faster - then either tell me or do it for me when needed we need something better… And its not something "NEW" in 18c, or 12c, …. Its something you already have !!!
  • #253: So to achieve our of goals - run fast - but keep an eye on how to run things faster - then either tell me or do it for me when needed we need something better… And its not something "NEW" in 18c, or 12c, …. Its something you already have !!!
  • #254: So to achieve our of goals - run fast - but keep an eye on how to run things faster - then either tell me or do it for me when needed we need something better… And its not something "NEW" in 18c, or 12c, …. Its something you already have !!!
  • #255: So to achieve our of goals - run fast - but keep an eye on how to run things faster - then either tell me or do it for me when needed we need something better… And its not something "NEW" in 18c, or 12c, …. Its something you already have !!!