Documente Academic
Documente Profesional
Documente Cultură
1 |Copyright © 2011 Oracle Corporation. Oracle and/or its affiliates. All rights reserved. Oracle Proprietary and Confidential
Agenda
2 |Copyright © 2011 Oracle Corporation. Oracle and/or its affiliates. All rights reserved. Oracle Proprietary and Confidential
Session 1: Overview of SQL Processing Review
3 |Copyright © 2011 Oracle Corporation. Oracle and/or its affiliates. All rights reserved. Oracle Proprietary and Confidential
Session 1:Overview of SQL Processing Review
• Without enough information, Optimizer can't optimize
its tasks.
4 |Copyright © 2011 Oracle Corporation. Oracle and/or its affiliates. All rights reserved. Oracle Proprietary and Confidential
Session 2: Performance Diagnostics Review
• Close to 90% of the performance issues worked on by
EBS development are related to SQL processing.
5 |Copyright © 2011 Oracle Corporation. Oracle and/or its affiliates. All rights reserved. Oracle Proprietary and Confidential
Session 3: Understanding the execution Review
plan
• Cardinality– Estimate of the number of rows coming out of
each of the operations.
• Access method – The way in which the data is being
accessed, via either a table scan or index access.
• Join method – The method (e.g., hash, sort-merge, etc.)
used to join tables with each other.
• Join type – The type of join (e.g., outer, anti, semi, etc.).
• Join order – The order in which the tables are joined to
each other.
6 |Copyright © 2011 Oracle Corporation. Oracle and/or its affiliates. All rights reserved. Oracle Proprietary and Confidential
Session 4: Basic Hints and their
Usage
7 |Copyright © 2011 Oracle Corporation. Oracle and/or its affiliates. All rights reserved. Oracle Proprietary and Confidential
Why use Hints?
8 |Copyright © 2011 Oracle Corporation. Oracle and/or its affiliates. All rights reserved. Oracle Proprietary and Confidential
Using Hints
9 |Copyright © 2011 Oracle Corporation. Oracle and/or its affiliates. All rights reserved. Oracle Proprietary and Confidential
Hints by Category
10 |Copyright © 2011 Oracle Corporation. Oracle and/or its affiliates. All rights reserved. Oracle Proprietary and Confidential
Hints for Optimization Approaches and
Goals
• ALL_ROWS: Uses cost based approach for the best
throughput. This is the default approach in 11G
SELECT /*+ ALL_ROWS */ trx_number
FROM ra_customer_trx_all;
• FIRST_ROWS(n): Uses cost based approach for the best
response time.
SELECT /*+ FIRST_ROWS(30) trx_number
FROM ra_customer_trx_all
ORDER BY customer_trx_id;
• CHOOSE: If statistics are available use CBO, otherwise
use RBO
11 |Copyright © 2011 Oracle Corporation. Oracle and/or its affiliates. All rights reserved. Oracle Proprietary and Confidential
Hints for Access Paths
• FULL: This tells the optimizer to do a full scan of the
specified table
SELECT /*+ FULL(ct) */ trx_number
FROM ra_customer_trx_all ct;
• INDEX: Forces an index scan of the specified table using
the specified index
SELECT /*+ INDEX(ct RA_CUSTOMER_TRX_N1)
trx_number
FROM ra_customer_trx_all ct;
• NO_INDEX: This tells the optimizer not to use a specific
index
12 |Copyright © 2011 Oracle Corporation. Oracle and/or its affiliates. All rights reserved. Oracle Proprietary and Confidential
Hints for Query Transformations
• MERGE and NO_MERGE
View merging simply means the query is rewritten without
the view. It is as if instead of:
select * from table, VIEW;
we actually typed in the VIEW text.
• select e.first_name, e.last_name, dept_locs_v.street_address,
dept_locs_v.postal_code from employees e,
(select d.department_id, d.department_name, l.street_address, l.postal_code
from departments d, locations l where d.location_id = l.location_id)
dept_locs_v
where dept_locs_v.department_id = e.department_id and e.last_name =
'Smith';
• When the MERGE hint is used without an argument, it
should be placed in the view query block.
When MERGE is used with the view name as an
argument, it should be placed in the surrounding query.
13 |Copyright © 2011 Oracle Corporation. Oracle and/or its affiliates. All rights reserved. Oracle Proprietary and Confidential
Hints for Query Transformations
• UNNEST and NO_UNNEST
UNNEST allows a subquery to be rewritten as a join, so that
select * from t1
where exists (select null from t2 where t2.key = t1.key)
can be rewritten by unnesting the subquery and joining to it
select t1.* from t1, t2 where t2.key = t1.key;
if that is deemed more efficient.
• Ex. UPDATE ar_cash_receipt_history_all
SET …….
WHERE posting_control_id = -3
AND (cash_receipt_id, event_id) IN
(SELECT /*+ UNNEST) ev. source_id_int_1, ev.event_id
FROM xla_post_acctg_events_v ev
…………….. );
14 |Copyright © 2011 Oracle Corporation. Oracle and/or its affiliates. All rights reserved. Oracle Proprietary and Confidential
Hints for Join Orders
• LEADING: Give this hint to indicate the leading table in a
join.
SELECT /*+ LEADING(adj) */ ps.customer_trx_id
FROM ar_adjustments adj,
ar_payment_schedules ps
WHERE ……..
• ORDERED: The ORDERED hint causes Oracle to join
tables in the order in which they appear in the FROM
clause
SELECT /*+ ORDERED */ ps.customer_trx_id
FROM ar_adjustments adj,
ar_payment_schedules ps
WHERE ……..
15 |Copyright © 2011 Oracle Corporation. Oracle and/or its affiliates. All rights reserved. Oracle Proprietary and Confidential
Hints for Join Operations
• USE_NL: The USE_NL hint causes Oracle to join each
specified table to another row source with a nested loops
join using the specified table as the inner table.
SELECT /*+ USE_NL(adj, ps) */ ps.customer_trx_id
FROM ar_adjustments adj,
ar_payment_schedules ps
WHERE ……..
• USE_HASH: The USE_HASH hint causes Oracle to join
each specified table with another row source with a hash
join.
SELECT /*+ USE_HASH(adj, ps) */ ps.customer_trx_id
FROM ar_adjustments adj,
ar_payment_schedules ps
WHERE ……..
16 |Copyright © 2011 Oracle Corporation. Oracle and/or its affiliates. All rights reserved. Oracle Proprietary and Confidential
Hints for Parallel Execution
• PARALLEL: The PARALLEL hint allows you to specify the
desired number of concurrent query servers that can be
used for the query.
INSERT /*+ parallel(a) append */ into ar_autorec_interim a
………………
17 |Copyright © 2011 Oracle Corporation. Oracle and/or its affiliates. All rights reserved. Oracle Proprietary and Confidential
Additional Hints
• APPEND: When the APPEND hint is used with the
INSERT statement, data is appended to the table. Existing
free space in the block is not used.
INSERT /*+ parallel(a) append */ into ar_autorec_interim a
………………
• PUSH_PRED: The PUSH_PRED hint forces pushing of a
join predicate into the view or an inline view.
SELECT /*+ PUSH_PRED(trx_extn) */ …..
FROM ar_cash_receipts cr,
(SELECT ….
FROM iby_fndcpt_tx_operations
WHERE …..) trx_extn
WHERE ….
AND cr. payment_trxn_extension_id = trxn_ext.trxn_extension_id(+) ……
18 |Copyright © 2011 Oracle Corporation. Oracle and/or its affiliates. All rights reserved. Oracle Proprietary and Confidential
Additional Hints
• PUSH_SUBQ: The PUSH_SUBQ hint causes nonmerged
subqueries to be evaluated at the earliest possible place in
the execution plan.
SELECT L.INTERFACE_LINE_ID, ….
FROM RA_INTERFACE_LINES_GT L
WHERE …..
AND NOT EXISTS
(SELECT /*+ PUSH_SUBQ NO_UNNEST */ 'X'
FROM MTL_ITEM_UOMS_VIEW UOM
…………..)
…………;
19 |Copyright © 2011 Oracle Corporation. Oracle and/or its affiliates. All rights reserved. Oracle Proprietary and Confidential
When to use Hints?
• Hints are the path of last resort.
20 |Copyright © 2011 Oracle Corporation. Oracle and/or its affiliates. All rights reserved. Oracle Proprietary and Confidential
Session 4: Basic Hints and their
Usage
• Try to understand the intention behind the suggestions
provided by the performance team when they ask us to
add Hints.
21 |Copyright © 2011 Oracle Corporation. Oracle and/or its affiliates. All rights reserved. Oracle Proprietary and Confidential