SlideShare una empresa de Scribd logo
1 de 102
www.sagecomputing.com.au
penny@sagecomputing.com.au
OHarmony – Finding Your Perfect Match
How the Optimizer Works
Penny Cookson
SAGE Computing Services
SAGE Computing Services
Customised Oracle Training Workshops and Consulting
WARNING
This presentation contains material which is not politically correct
Includes adult concepts
May contain strong language
SAGE Computing Services
Customised Oracle Training Workshops and Consulting
Penny Cookson
Managing Director and Principal Consultant
Working with Oracle products since 1987
Oracle Magazine Educator of the Year 2004
www.sagecomputing.com.au
penny@sagecomputing.com.au
Optimiser Step 1 - Transformation
Query rewrite for
materialised views
Transitive conditions
OR expansion
View merging
Predicate pushing
Join factorisation
COL1 = :B1
AND COL2 >= :B2 AND COL2 < :B3
AND COL3 >= :B4
AND COL4 = :B5
…………………………………….
Col1 Col2 Col3 Col4 Col5 Col6
How many of these
are there likely to
be?
How many rows will be returned?
There are 23 million rows in this table
ATTRIBUTE1 = :B1
AND ATTRIBUTE2 >= :B2
AND ATTRIBUTE2 < :B3
AND ATTRIBUTE3 >= :B4
AND ATTRIBUTE4 = :B5
How many
of these are
there likely
to be?
Looking for your perfect match
There are 11 million males
in Australia
MARRIED = ‘N’
AND AGE >=25 AND AGE <30
AND HEIGHT >= 6ft 2 in
AND JOB=‘DBA’
How many
of these are
there likely
to be?
There are 11 million males
in Australia
The attribute Married
has two distinct
values Yes or No
50% 50%
We assume 50% of
each
How many people
satisfy the criteria
Married = ‘N’?
There are 11 million
males in Australia
Number of Unmarried males is
11,000,000/2 = 5,500,000
How many people satisfy the criteria Married = ‘N’?
More Statistics
6 in every 10 males are
married
So - Number of Unmarried males
is 4,400,000
This is what we did originally
begin
dbms_stats.gather_schema_stats
(ownname=>'AUSOUG',
method_opt => 'for all columns size 1' );
end;
How can Oracle get better statistics?
begin
dbms_stats.gather_table_stats
(ownname=>'AUSOUG',
tabname=>'MEN',
method_opt => 'for all columns size 1,
for columns size auto married' );
end;
Create a histogram only for Married
This is no longer relevant Because we have this
Cummulative
http://jonathanlewis.wordpress.com/2010/10/05/frequency-histogram-4/
SELECT /*+ GATHER_PLAN_STATISTICS */ COUNT(*)
FROM men
WHERE married = 'N‘;
SELECT dbms_xplan.display_cursor
('5zyycq4y22j9g',format=>'ALLSTATS LAST')
FROM dual;
Now it gets it right
MARRIED = ‘N’
AND AGE >=25 AND AGE <30
AND HEIGHT >= 6ft 2 in
AND JOB=‘DBA’
How many
of these are
there likely
to be?
There are 11 million males
in Australia
MARRIED = ‘N’  40% 
Age statistics
8.2% of men are BETWEEN
25 and 29
Age statistics
SELECT /*+ GATHER_PLAN_STATISTICS */ COUNT(*)
FROM men
WHERE age >=25 and age < 30;
create or replace function raw_to_num(i_raw raw)
return number as m_n number;
begin
dbms_stats.convert_raw_value(i_raw,m_n);
return m_n;
end;
/
create or replace function raw_to_date(i_raw raw)
return date as m_n date;
begin
dbms_stats.convert_raw_value(i_raw,m_n);
return m_n;
end;
/
create or replace function raw_to_varchar2(i_raw raw)
return varchar2 as m_n varchar2(20);
begin
dbms_stats.convert_raw_value(i_raw,m_n);
return m_n;
end;
/
http://jonathanlewis.wordpress.com/2006/11/29/low_value-high_value/
SELECT
column_name,
decode(data_type,
'VARCHAR2',to_char(raw_to_varchar2(low_value)),
'DATE',to_char(raw_to_date(low_value)),
'NUMBER',to_char(round(raw_to_num(low_value),2))
) low_value,
decode(data_type,
'VARCHAR2',to_char(raw_to_varchar2(high_value)),
'DATE',to_char(raw_to_date(high_value)),
'NUMBER',to_char(round(raw_to_num(high_value),2))
) high_value
FROM user_tab_columns
WHERE table_name='MEN';
http://jonathanlewis.wordpress.com/2006/11/29/low_value-high_value/
5.10204… % * 11,000,000 = 561,224
0 98
25 30
SELECT TRUNC(11000000*(30-25)/(98)),trunc((30-25)/(98)*100,6) from dual
Add a histogram
begin
dbms_stats.gather_table_stats(ownname=>'AUSOUG',
tabname=>'MEN',
method_opt =>
'for all columns size 1 for columns size auto married, for columns size
254 age ' );
end;
SELECT
trunc(h.endpoint_value,2)
,h.endpoint_repeat_count
from user_tab_histograms h, user_tables t
WHERE t.table_name = h.table_name
AND h.table_name = 'MEN'
AND h.column_name = 'AGE'
ORDER BY endpoint_value
SELECT /*+ GATHER_PLAN_STATISTICS */ COUNT(*)
FROM men
WHERE age >=25 and age < 30;
SELECT
dbms_xplan.display_cursor('6aub3fn962277',format=>'ALLSTATS LAST')
FROM dual
Not perfect but better
MARRIED = ‘N’
AND AGE >=25 AND AGE <30
AND HEIGHT >= 6ft 2 in (188cm)
AND JOB=‘DBA’
How many
of these are
there likely
to be?
There are 11 million males
in Australia
MARRIED = ‘N’  40%
AND AGE >=25 AND <30  8.2%


SELECT /*+ GATHER_PLAN_STATISTICS */ COUNT(*)
FROM men
WHERE height >= 188
SELECT dbms_xplan.display_cursor('bf4wbtgb9zptq',
format=>'ALLSTATS LAST')
FROM dual
How many men are >= 188cm (we have gathered a histogram)
MARRIED = ‘N’
AND AGE >=25 AND AGE <30
AND HEIGHT >= 6ft 2 in (188cm)
AND JOB=‘DBA’
How many
of these are
there likely
to be?
There are 11 million males
in Australia
MARRIED = ‘N’  40%
AND AGE >=25 AND <30  8.2%
AND HEIGHT >= 6ft 2 in (188cm)  2.9%



11000000*40/100 *8.2/100 * 2.9/100 =10,463
MARRIED = ‘N’  40%
AND AGE >=25 AND <30  8.2%
AND HEIGHT >= 6ft 2 in (188cm)  2.9%
SELECT /*+ GATHER_PLAN_STATISTICS */ COUNT(*)
FROM men
WHERE married = 'N'
AND age >=25 AND age < 30
AND height >= 188
Height Statistics
5.3% of males are >= 6ft 2inches
Are these
statistics out of
date?
- do select of
last_analyzed
5.3% of males are >= 6ft 2inches
Note the
correlation
between
gender, age and
height
SELECT c.column_name, t.num_rows "Number of Rows",
c.num_distinct "Distinct Values",
c.histogram "Histogram"
FROM user_tables t, user_tab_col_statistics c
WHERE t.table_name = c.table_name
AND t.table_name = 'MEN'
SELECT /*+ GATHER_PLAN_STATISTICS */
COUNT(*)
FROM men
WHERE age =6
AND height = 174
BEGIN
dbms_stats.gather_table_stats(ownname=>'AUSOUG',
tabname=>'MEN', estimate_percent=>NULL,
method_opt =>
'for all columns size 1 for columns size auto married height, for
columns size 254 age, for columns (age, height) size 2048 ' );
END;
Gather extended statistics
SELECT *
FROM dba_stat_extensions
WHERE table_name = 'MEN'
SELECT c.column_name, t.num_rows "Number of Rows",
c.num_distinct "Distinct Values",
c.histogram "Histogram"
FROM user_tables t, user_tab_col_statistics c
WHERE t.table_name = c.table_name
AND t.table_name = 'MEN'
SELECT /*+ GATHER_PLAN_STATISTICS */ COUNT(*)
FROM men
WHERE age =6
AND height = 174
ALTER SESSION SET EVENTS ' 10053 trace name context forever ‘;
EXPLAIN PLAN FOR …………;
ALTER SESSION SET EVENTS ' 10053 trace name context off ‘;
SELECT /*+ GATHER_PLAN_STATISTICS */
COUNT(*)
FROM men
WHERE age = 30
AND height = 174
SELECT /*+ GATHER_PLAN_STATISTICS */ COUNT(*)
FROM men
WHERE married = 'N'
AND age >=25 AND age < 30
AND height >= 188
When we combine range checks it gets it wrong
10053 trace file – its not looking at the extended stats
ALTER SESSION SET EVENTS ' 10053 trace name context forever ‘;
EXPLAIN PLAN FOR …………;
ALTER SESSION SET EVENTS ' 10053 trace name context off ‘;
BEGIN
DBMS_STATS.DROP_EXTENDED_STATS('AUSOUG', 'MEN',
'("AGE","HEIGHT","MARRIED")') ;
END;
BEGIN
dbms_stats.purge_stats(sysdate);
END;
What about Statistics Feedback?
Execute again
begin
dbms_spd.flush_sql_plan_directive;
end;
Clear any existing SQL Plan Directives
SELECT d.directive_id, d.type, d.state, d.reason, d.created,
o.object_name, o.subobject_name, o.notes, o.owner
FROM dba_sql_plan_directives d, dba_sql_plan_dir_objects o
WHERE o.directive_id = d.directive_id
AND o.owner NOT IN ('XDB','SYS','SYSTEM')
ORDER BY directive_id desc;
begin
dbms_spd.drop_sql_plan_directive(3579438123315094543);
end;
ALTER SYSTEM FLUSH shared_pool;
ALTER SESSION SET statistics_level = ALL;
Clear any existing plans and gather plan
statistics
Execute each of these twice
Only the last two use
statistics feedback
UNMARRIED = ‘Y’
AND AGE >=25 AND AGE <30
AND HEIGHT >= 6ft 2 in (188cm)
AND JOB=‘DBA’
How many
of these are
there likely
to be?
There are 11 million males
in Australia
UNMARRIED = ‘Y’  40%
AND AGE >=25 AND <30  8.2%
AND HEIGHT >= 6ft 2 in (188cm)  2.9%
We have no idea what percentage of males are DBAs



begin
dbms_stats.delete_schema_stats(ownname=>'AUSOUG' );
end;
SELECT COUNT(*)
FROM men
WHERE job = 'DBA'
Actual value is 1,000,014
Now we know how many matches to expect
what is the best way to get to them
Two main types:
Pretty cruisy really – almost anyone will do
Really very picky – he must be just right
The Oracle approach to
Pretty cruisy really – almost anyone will do
SELECT COUNT(*)
FROM men
WHERE age >=20 AND age < 50
AND married = 'N'
AND job != 'LAWYER'
Full table scan
WHERE col1 = ' bbbbb '
aaaaa
bbbbb
ccccc
ddddd
eeeee
aaaaa
ggggg
ccccc
ddddd
eeeee
aaaaa
kkkkk
ccccc
ddddd
eeeee
aaaaa
bbbbb
ccccc
ddddd
eeeee
aaaaa
bbbbb
bbbbb
ddddd
eeeee
Multi
block
read
SELECT COUNT(*)
FROM men
WHERE age >=20 AND age < 50
AND married = 'N'
AND job != 'LAWYER'
Really very picky – he must be just right
OHarmony
I tell you what I want and you just give me
the phone numbers where I can contact
them
OHarmony
OHarmony
Brown
DBA
188
120,000
N
25Age From Age To 30
IQ (min)
Married
Smoker
Eyes
Height From
Salary (min annual)
120
N
195Height To
Preferred Job Type
OHarmony
Brown
DBA
188
120,000
N
25Age From Age To 30
IQ (min)
Married
Smoker
Eyes
Height From
Salary (min annual)
120
N
195Height To
Preferred Job Type
John Smith 9999 9999
Index range scan
a
z
bbbb rowid
bbbb rowid
aaaaa
bbbbb
ccccc
ddddd
eeeee
aaaaa
ggggg
ccccc
ddddd
eeeee
aaaaa
kkkkk
ccccc
ddddd
eeeee
aaaaa
bbbbb
ccccc
ddddd
eeeee
WHERE
col1 = ' bbbbb '
SELECT id, surname, firstname
FROM men
WHERE iq = 155;
SELECT COUNT(surname)
FROM men
WHERE iq > 154;
SELECT COUNT(surname)
FROM men
WHERE iq > 153;
9 rows
0.00008%
137,488 rows
1.25%
OHarmony
DEVELOPER
195
120,000
N
25Age From Age To 30
IQ (min)
Married
Smoker
Eyes
Height From
Salary (min annual)
N
Height To
Preferred Job Type
Oharmony has
provided
14 matches in
14 locations
Poorly clustered
Oharmony has
provided
14 matches in 2
locations
Well clustered
SELECT i.index_name, i.distinct_keys, i.num_rows,
i.clustering_factor, t.blocks
FROM user_indexes i, user_tables t
WHERE t.table_name = i.table_name
AND t.table_name = 'MEN';
CREATE TABLE men2
AS SELECT * FROM men
ORDER BY IQ;
CREATE INDEX MEN2_IQ_N4 ON men2(iq);
begin
dbms_stats.gather_table_stats(ownname=>'AUSOUG',
tabname=>'MEN2', estimate_percent => null,
cascade=>true,
method_opt =>
'for all columns size 1 for columns size 2000 iq ' );
end;
SELECT i.distinct_keys, i.num_rows,
i.clustering_factor, t.blocks
FROM user_indexes i, user_tables t
WHERE t.table_name = i.table_name
AND i.index_name = 'MEN2_IQ_N4';
previously
previously
Optimizer Mode
Optimizer Mode
All_Rows
First_Rows
Tends towards:
SELECT id, surname, firstname
FROM men
WHERE married = 'N'
AND age_range = '25-29'
AND height = 188
AND iq = 120
AND job = 'DBA';
Bitmap indexes
With Bitmap indexes
Sorting
With B*Tree indexes
SELECT id, surname, firstname
FROM men
WHERE married = 'N'
AND age_range = '25-29‘
AND height = 188
AND iq = 120
AND job= 'DBA';
access conditions
number of rows?
access method?
access conditions
number of rows?
access method?
access conditions
number of rows?
access method?
Identify each join path
How many rows am I likely to get?
What is the best join method?
All I have talked about so far is Access to one table
– how does it JOIN them together ?
access conditions
number of rows?
access method?
access conditions
number of rows?
access method?
access conditions
number of rows?
access method?
1
2
3
access conditions
number of rows?
access method?
access conditions
number of rows?
access method?
access conditions
number of rows?
access method?
1
2 3
access conditions
number of rows?
access method?
access conditions
number of rows?
access method?
access conditions
number of rows?
access method?
1
2 3
for each join path
for each join – what is the best JOIN METHOD?
Joins methods – Nested Loop with index
1 2
A.COL1 = B.COL2
A B
COL1 = 1
B.COL2
index
ACCESS
ROWS
WHERE
COL2 = 1
COL2 = 1
COL2 = 1
COL2 = 1
Joins methods – Hash join
A
B
HASH
TABLE1
Joins methods – cartesian
A
B
SELECT COUNT(*)
FROM men
WHERE married = 'N'
AND age < 12
AND height >= 188
The wrong plan 0 rows
0 rows
ALTER SESSION SET OPTIMIZER_INDEX_COST_ADJ = 5;
SELECT COUNT(*)
FROM men
WHERE married = 'N'
AND age < 12
AND height >= 188
This is even worse
SELECT /*+ INDEX_COMBINE(MEN MEN_AGE_N1,MEN_HEIGHT_N1) */ COUNT(*)
FROM men
WHERE married = 'N'
AND age < 12
AND height >= 188
0 rowsBetter
SELECT COUNT(surname)
FROM men
WHERE height between 159.4 AND 160
26188 rows
SELECT /*+ FULL(MEN) */ COUNT(surname)
FROM men
WHERE height between 159.4 AND 160
10,299,997 rowsSELECT COUNT(surname), COUNT( start_date)
FROM men m, events e
WHERE e.men_id (+) = m.id
AND m.iq = 156
SELECT /*+ USE_HASH(M,E) */ COUNT(surname), COUNT( start_date)
FROM men m, events e
WHERE e.men_id (+) = m.id
AND m.iq = 156
www.sagecomputing.com.au
penny@sagecomputing.com.au
Questions?
Penny Cookson
SAGE Computing Services
SAGE Computing Services
Customised Oracle Training Workshops and Consulting

Más contenido relacionado

Similar a OHarmony - How the Optimiser works

The ultimate-guide-to-sql
The ultimate-guide-to-sqlThe ultimate-guide-to-sql
The ultimate-guide-to-sqlMcNamaraChiwaye
 
Tracking Data Updates in Real-time with Change Data Capture
Tracking Data Updates in Real-time with Change Data CaptureTracking Data Updates in Real-time with Change Data Capture
Tracking Data Updates in Real-time with Change Data CaptureScyllaDB
 
Charles WilliamsCS362Unit 3 Discussion BoardStructured Query Langu.docx
Charles WilliamsCS362Unit 3 Discussion BoardStructured Query Langu.docxCharles WilliamsCS362Unit 3 Discussion BoardStructured Query Langu.docx
Charles WilliamsCS362Unit 3 Discussion BoardStructured Query Langu.docxchristinemaritza
 
Structured Query Language for Data Management 2 Sructu.docx
Structured Query Language for Data Management      2 Sructu.docxStructured Query Language for Data Management      2 Sructu.docx
Structured Query Language for Data Management 2 Sructu.docxjohniemcm5zt
 
The Ring programming language version 1.7 book - Part 10 of 196
The Ring programming language version 1.7 book - Part 10 of 196The Ring programming language version 1.7 book - Part 10 of 196
The Ring programming language version 1.7 book - Part 10 of 196Mahmoud Samir Fayed
 
Apurv Gupta, BCA ,Final year , Dezyne E'cole College
 Apurv Gupta, BCA ,Final year , Dezyne E'cole College Apurv Gupta, BCA ,Final year , Dezyne E'cole College
Apurv Gupta, BCA ,Final year , Dezyne E'cole Collegedezyneecole
 
The MySQL Query Optimizer Explained Through Optimizer Trace
The MySQL Query Optimizer Explained Through Optimizer TraceThe MySQL Query Optimizer Explained Through Optimizer Trace
The MySQL Query Optimizer Explained Through Optimizer Traceoysteing
 
Latin America Tour 2019 - 10 great sql features
Latin America Tour 2019  - 10 great sql featuresLatin America Tour 2019  - 10 great sql features
Latin America Tour 2019 - 10 great sql featuresConnor McDonald
 
Learning SAS by Example -A Programmer’s Guide by Ron CodySolution
Learning SAS by Example -A Programmer’s Guide by Ron CodySolutionLearning SAS by Example -A Programmer’s Guide by Ron CodySolution
Learning SAS by Example -A Programmer’s Guide by Ron CodySolutionVibeesh CS
 
e computer notes - Single row functions
e computer notes - Single row functionse computer notes - Single row functions
e computer notes - Single row functionsecomputernotes
 
The Ring programming language version 1.6 book - Part 9 of 189
The Ring programming language version 1.6 book - Part 9 of 189The Ring programming language version 1.6 book - Part 9 of 189
The Ring programming language version 1.6 book - Part 9 of 189Mahmoud Samir Fayed
 
Software Analytics In Action: A Hands-on Tutorial on Mining, Analyzing, Model...
Software Analytics In Action: A Hands-on Tutorial on Mining, Analyzing, Model...Software Analytics In Action: A Hands-on Tutorial on Mining, Analyzing, Model...
Software Analytics In Action: A Hands-on Tutorial on Mining, Analyzing, Model...Chakkrit (Kla) Tantithamthavorn
 
Chris Mc Glothen Sql Portfolio
Chris Mc Glothen Sql PortfolioChris Mc Glothen Sql Portfolio
Chris Mc Glothen Sql Portfolioclmcglothen
 
PROCEDURE FOR MONTH END DAY 1 INCLUDING SCREEN SHOT & SCRIPTS (Final rev 090211)
PROCEDURE FOR MONTH END DAY 1 INCLUDING SCREEN SHOT & SCRIPTS (Final rev 090211)PROCEDURE FOR MONTH END DAY 1 INCLUDING SCREEN SHOT & SCRIPTS (Final rev 090211)
PROCEDURE FOR MONTH END DAY 1 INCLUDING SCREEN SHOT & SCRIPTS (Final rev 090211)Shakil Zaman
 
Tony jambu (obscure) tools of the trade for tuning oracle sq ls
Tony jambu   (obscure) tools of the trade for tuning oracle sq lsTony jambu   (obscure) tools of the trade for tuning oracle sq ls
Tony jambu (obscure) tools of the trade for tuning oracle sq lsInSync Conference
 

Similar a OHarmony - How the Optimiser works (20)

The ultimate-guide-to-sql
The ultimate-guide-to-sqlThe ultimate-guide-to-sql
The ultimate-guide-to-sql
 
Tracking Data Updates in Real-time with Change Data Capture
Tracking Data Updates in Real-time with Change Data CaptureTracking Data Updates in Real-time with Change Data Capture
Tracking Data Updates in Real-time with Change Data Capture
 
Charles WilliamsCS362Unit 3 Discussion BoardStructured Query Langu.docx
Charles WilliamsCS362Unit 3 Discussion BoardStructured Query Langu.docxCharles WilliamsCS362Unit 3 Discussion BoardStructured Query Langu.docx
Charles WilliamsCS362Unit 3 Discussion BoardStructured Query Langu.docx
 
Structured Query Language for Data Management 2 Sructu.docx
Structured Query Language for Data Management      2 Sructu.docxStructured Query Language for Data Management      2 Sructu.docx
Structured Query Language for Data Management 2 Sructu.docx
 
The Ring programming language version 1.7 book - Part 10 of 196
The Ring programming language version 1.7 book - Part 10 of 196The Ring programming language version 1.7 book - Part 10 of 196
The Ring programming language version 1.7 book - Part 10 of 196
 
Apurv Gupta, BCA ,Final year , Dezyne E'cole College
 Apurv Gupta, BCA ,Final year , Dezyne E'cole College Apurv Gupta, BCA ,Final year , Dezyne E'cole College
Apurv Gupta, BCA ,Final year , Dezyne E'cole College
 
February0504 pm
February0504 pmFebruary0504 pm
February0504 pm
 
The MySQL Query Optimizer Explained Through Optimizer Trace
The MySQL Query Optimizer Explained Through Optimizer TraceThe MySQL Query Optimizer Explained Through Optimizer Trace
The MySQL Query Optimizer Explained Through Optimizer Trace
 
Cluto presentation
Cluto presentationCluto presentation
Cluto presentation
 
Latin America Tour 2019 - 10 great sql features
Latin America Tour 2019  - 10 great sql featuresLatin America Tour 2019  - 10 great sql features
Latin America Tour 2019 - 10 great sql features
 
Learning SAS by Example -A Programmer’s Guide by Ron CodySolution
Learning SAS by Example -A Programmer’s Guide by Ron CodySolutionLearning SAS by Example -A Programmer’s Guide by Ron CodySolution
Learning SAS by Example -A Programmer’s Guide by Ron CodySolution
 
e computer notes - Single row functions
e computer notes - Single row functionse computer notes - Single row functions
e computer notes - Single row functions
 
The Ring programming language version 1.6 book - Part 9 of 189
The Ring programming language version 1.6 book - Part 9 of 189The Ring programming language version 1.6 book - Part 9 of 189
The Ring programming language version 1.6 book - Part 9 of 189
 
SQL logical operators
SQL logical operatorsSQL logical operators
SQL logical operators
 
Airline delay prediction
Airline delay predictionAirline delay prediction
Airline delay prediction
 
Software Analytics In Action: A Hands-on Tutorial on Mining, Analyzing, Model...
Software Analytics In Action: A Hands-on Tutorial on Mining, Analyzing, Model...Software Analytics In Action: A Hands-on Tutorial on Mining, Analyzing, Model...
Software Analytics In Action: A Hands-on Tutorial on Mining, Analyzing, Model...
 
Chris Mc Glothen Sql Portfolio
Chris Mc Glothen Sql PortfolioChris Mc Glothen Sql Portfolio
Chris Mc Glothen Sql Portfolio
 
PROCEDURE FOR MONTH END DAY 1 INCLUDING SCREEN SHOT & SCRIPTS (Final rev 090211)
PROCEDURE FOR MONTH END DAY 1 INCLUDING SCREEN SHOT & SCRIPTS (Final rev 090211)PROCEDURE FOR MONTH END DAY 1 INCLUDING SCREEN SHOT & SCRIPTS (Final rev 090211)
PROCEDURE FOR MONTH END DAY 1 INCLUDING SCREEN SHOT & SCRIPTS (Final rev 090211)
 
Tony jambu (obscure) tools of the trade for tuning oracle sq ls
Tony jambu   (obscure) tools of the trade for tuning oracle sq lsTony jambu   (obscure) tools of the trade for tuning oracle sq ls
Tony jambu (obscure) tools of the trade for tuning oracle sq ls
 
Sql
SqlSql
Sql
 

Más de Sage Computing Services

Bind Peeking - The Endless Tuning Nightmare
Bind Peeking - The Endless Tuning NightmareBind Peeking - The Endless Tuning Nightmare
Bind Peeking - The Endless Tuning NightmareSage Computing Services
 
Back to basics: Simple database web services without the need for SOA
Back to basics: Simple database web services without the need for SOABack to basics: Simple database web services without the need for SOA
Back to basics: Simple database web services without the need for SOASage Computing Services
 
Whose fault is it? - a review of application tuning problems
Whose fault is it? - a review of application tuning problemsWhose fault is it? - a review of application tuning problems
Whose fault is it? - a review of application tuning problemsSage Computing Services
 
New Tuning Features in Oracle 11g - How to make your database as boring as po...
New Tuning Features in Oracle 11g - How to make your database as boring as po...New Tuning Features in Oracle 11g - How to make your database as boring as po...
New Tuning Features in Oracle 11g - How to make your database as boring as po...Sage Computing Services
 
How Can I tune it When I Can't Change the Code?
How Can I tune it When I Can't Change the Code?How Can I tune it When I Can't Change the Code?
How Can I tune it When I Can't Change the Code?Sage Computing Services
 
Take a load off! Load testing your Oracle APEX or JDeveloper web applications
Take a load off! Load testing your Oracle APEX or JDeveloper web applicationsTake a load off! Load testing your Oracle APEX or JDeveloper web applications
Take a load off! Load testing your Oracle APEX or JDeveloper web applicationsSage Computing Services
 
Transformations - how Oracle rewrites your statements
Transformations - how Oracle rewrites your statementsTransformations - how Oracle rewrites your statements
Transformations - how Oracle rewrites your statementsSage Computing Services
 
Application Express - A web development environment for the masses - and for ...
Application Express - A web development environment for the masses - and for ...Application Express - A web development environment for the masses - and for ...
Application Express - A web development environment for the masses - and for ...Sage Computing Services
 
Oracle Discoverer is dead - Where to next for BI?
Oracle Discoverer is dead - Where to next for BI?Oracle Discoverer is dead - Where to next for BI?
Oracle Discoverer is dead - Where to next for BI?Sage Computing Services
 

Más de Sage Computing Services (16)

Oracle XML DB - What's in it for me?
Oracle XML DB - What's in it for me?Oracle XML DB - What's in it for me?
Oracle XML DB - What's in it for me?
 
Aspects of 10 Tuning
Aspects of 10 TuningAspects of 10 Tuning
Aspects of 10 Tuning
 
Bind Peeking - The Endless Tuning Nightmare
Bind Peeking - The Endless Tuning NightmareBind Peeking - The Endless Tuning Nightmare
Bind Peeking - The Endless Tuning Nightmare
 
Back to basics: Simple database web services without the need for SOA
Back to basics: Simple database web services without the need for SOABack to basics: Simple database web services without the need for SOA
Back to basics: Simple database web services without the need for SOA
 
Results cache
Results cacheResults cache
Results cache
 
Vpd
VpdVpd
Vpd
 
Whose fault is it? - a review of application tuning problems
Whose fault is it? - a review of application tuning problemsWhose fault is it? - a review of application tuning problems
Whose fault is it? - a review of application tuning problems
 
New Tuning Features in Oracle 11g - How to make your database as boring as po...
New Tuning Features in Oracle 11g - How to make your database as boring as po...New Tuning Features in Oracle 11g - How to make your database as boring as po...
New Tuning Features in Oracle 11g - How to make your database as boring as po...
 
Lost without a trace
Lost without a traceLost without a trace
Lost without a trace
 
How Can I tune it When I Can't Change the Code?
How Can I tune it When I Can't Change the Code?How Can I tune it When I Can't Change the Code?
How Can I tune it When I Can't Change the Code?
 
Meet the CBO in Version 11g
Meet the CBO in Version 11gMeet the CBO in Version 11g
Meet the CBO in Version 11g
 
Take a load off! Load testing your Oracle APEX or JDeveloper web applications
Take a load off! Load testing your Oracle APEX or JDeveloper web applicationsTake a load off! Load testing your Oracle APEX or JDeveloper web applications
Take a load off! Load testing your Oracle APEX or JDeveloper web applications
 
The Cost Based Optimiser in 11gR2
The Cost Based Optimiser in 11gR2The Cost Based Optimiser in 11gR2
The Cost Based Optimiser in 11gR2
 
Transformations - how Oracle rewrites your statements
Transformations - how Oracle rewrites your statementsTransformations - how Oracle rewrites your statements
Transformations - how Oracle rewrites your statements
 
Application Express - A web development environment for the masses - and for ...
Application Express - A web development environment for the masses - and for ...Application Express - A web development environment for the masses - and for ...
Application Express - A web development environment for the masses - and for ...
 
Oracle Discoverer is dead - Where to next for BI?
Oracle Discoverer is dead - Where to next for BI?Oracle Discoverer is dead - Where to next for BI?
Oracle Discoverer is dead - Where to next for BI?
 

Último

Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceanilsa9823
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 

Último (20)

Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 

OHarmony - How the Optimiser works

Notas del editor

  1. FAVOURITE NEW KNOW SOME ALL - BEER
  2. BEER AMERICA TOPLESS
  3. HOW MANY
  4. HOW MANY
  5. ANALOGY WORKS FOUND STUFF OUT MALE v FEMALE
  6. TALL DBAs
  7. SMILING DRESSED UP
  8. OPTIMSER’S RULES
  9. REALITY v ASSUMPTIONS 80%ALIENS 74%GOD 5% HOWARD
  10. WE KNOW – EXPERIENCE/RESEARCH ORACLE KNOWS? DEV / DBA GAP
  11. NUMBER OF OCCURENCES
  12. CUMMULATIVE 15 BYTES -> PAD -> TREAT AS HEX -> CONV TO DEC -> ROUND -> ENDPOINT VALUE Value: Take the first 15 bytes of the string (after padding the string with nulls (for varchar2) or spaces (for char)) Treat the result as a hexadecimal number, and convert to decimal Round to 15 significant digits and store as the endpoint_value If duplicate rows appear, store the first 32 characters (increased to 64 for 12c) of each string as the endpoint_actual_value
  13. WHAT ORACLE THINKS – IS IT RIGHT? REVERSE Take the first 15 bytes of the string (after padding the string with nulls (for varchar2) or spaces (for char)) Treat the result as a hexadecimal number, and convert to decimal Round to 15 significant digits and store as the endpoint_value If duplicate rows appear, store the first 32 characters (increased to 64 for 12c) of each string as the endpoint_actual_value to_char(endpoint_value,'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') – -> ‘X is hexadecimal format
  14. GATHER PLAN STATISTICS ALTER SESSION SET STATISTICS_LEVEL = ALL
  15. NEXT CONDITION TOGTHER LATER
  16. GOOGLE
  17. OURS MATCHES
  18. NUMBERS FROM ????
  19. REFERENCE ROUTINE FOR EACH DATATYPE
  20. DECODE!!!! HIGH_VALUE, LOW_VALUE – USER_TAB_COL_STATISTICS
  21. 0 TO 98 ISH
  22. EXPECTING 550000
  23. HYBRID v 12 SQUEEZE BUCKETS Hybrid – new in v12 (also 2048 buckets not 254 To handle “almost popular” values Endpoint for each “popular value” is repeat count
  24. SOME OF 1s WOULD NOT HAVE MADE IT IN HEIGHT-BALANCED
  25. FREQUENCY – PERFECT HYBRID - NOT
  26. HEIGHT – SAME APPROACH - Looking good
  27. IGNORE JOB COMBINE THREE
  28. WRONG (ROUNDING)
  29. INTERESTINH HEIGHT STUFF GRATUITOUS SIX PACK – TOPLESS FORTUNE 500 CEOs BETTER GIRLFRIENDS
  30. 1988 - 94
  31. SINCE WE ARE PUTTING TOGETHER CORRELATION
  32. CURRENT STATS PICTURE SEO HISTOGRAMS
  33. TALL 6 YEAR OLDS - DON’T ASSUME OPTIMIZER KNOWS WHAT WE KNOW
  34. EXTENDED STATS 11
  35. HYBRID TOO MANY FOR FREQUECY COMMON FOR EXTENDED - COMBINATIONS
  36. MAJORITIES GOOD MINORITIES NOT
  37. 10053 TRACE DEFAULT DENSITY
  38. MAJORITY
  39. EXTENDED STATS NOT USER Not used stats on 3 columns Create virtual column – cannot use in extended statistics - well ys you can if you create an index first (from 11.2.0.3) or persist it – but didn’t seem to use anyway. (for 3 ?how about 2) begin dbms_stats.gather_table_stats(ownname=>'AUSOUG', tabname=>'MEN', method_opt => 'for all columns size 1 for columns size auto married height, for columns size 2000 age age_range (age_range, married) ' ); end; Since it doesn’t help I have removed the stats on this
  40. WTF?????
  41. 11g 12 MORE + PERSISTENT
  42. SECOND TIME IS_REOPTIMIZABLE
  43. NEW CHILD CURSOR ORACLE FIX IT?
  44. CLEAN UP
  45. MORE CLEAN UP
  46. SAME SRESULTS
  47. NO CLUE ASK
  48. SAMPLE
  49. SUMMARY: GOOD STATS HISTOGRAMS EXTENDED STATS CARD FEEDBACK DYNAMIC
  50. BACK TO ANALOGY
  51. LAWYER
  52. READ THEM ALL FILTER OUT THE ONES WE WANT
  53. GO TO SOURCE WHICH HELPS LOCATE THEM
  54. SELECTION CRITERIA
  55. MOBILES
  56. GO TO SOURCE THAT LOCATES ROWS THAT MATCH MODIFIED COLUMNS _ LYING
  57. 12c BATCHED /*+ NO_BATCH_TABLE_ACCESS_BY_ROWID(i)*/ alter session set "_optimizer_batch_table_access_by_rowid"=FALSE; access rows in block order to improve the clustering and reduce the number of times that the database must access a block. Cannot use if using index for sort ?whole presentation on this ?effect on clustering factor
  58. HOW DECIDE CUT OFF?
  59. SERIOUSLY TALL DEVELOPER
  60. DEVELOPER PLAYING FOR WILDCATS - STRETCHING
  61. IQ AS EXAMPLE
  62. 10043 TRACE
  63. BIT LESS - INDEX SINGLE BLOCK READ
  64. CREATE WELL CLUSTERED
  65. NOT SUGGESTING REORDER ALL
  66. SUMMARY – FULL / INDEXES
  67. YOUR CONTROL
  68. READ ONLY EQUALITY STAND UP - DBA - SIT NOT 25-29 - SIT HEIGHT < 6FT?
  69. EQUALITIES NOT RANGE
  70. HOW PUTS TOGETHER
  71. SEE IN 10053
  72. NUMBER OF PATHS N FACTORIAL
  73. NOT ALL
  74. HOW SAME STORY – HOW MANY
  75. TRANSACTIONAL
  76. BUT NOT ONE TO ONE
  77. HASH JOIN MORE ROWS – WORTH FULL SCAN
  78. WHERE? SUMMARY
  79. Data dependency issue
  80. Minority values
  81. Does not use histogram on events for join Iq 156 = record 2 who has