Advanced Oracle SQL Tuning
Advanced Oracle SQL Tuning
You will learn how access path operators fetch rows from database segments and how the
rows are passed through the execution plan tree throughout the lifecycle of SQL
execution. You will also learn how row joining, filtering and comparison works, such as
nested loop/hash joins and also the frequently seen FILTER operation.
The understanding of how SQL plan execution physically works will become a strong
and required foundation for any systematic SQL tuning and troubleshooting task.
Understanding why can SQL performance change even though the execution plan hasn’t
changed
• Amount of work area memory allowed to use by work area manager
• Hash multipass join decisions
• Dynamic hash input swapping
• Number of parallel slaves currently available
• Runtime prefetching decisions
o Nested loop prefetching
o Direct read segment scan prefetching
o Index multiblock read prefetching
We will start from identifying important prerequisites to any systematic SQL tuning, such
as understanding the amount and “shape” of data accessed and what is the SQL statement
supposed to do. This allows you to understand what would be the ideal execution order
and hierarchy – which you can then achieve with the techniques covered next in this
section.
As no SQL tuning technique is appropriate in all situations, we will also look into how to
pick the right technique for fixing the right problem and common SQL optimization
pitfalls.
Making the SQL execution plan do exactly what you want – and always
• Hinting the right way
• Hinting pitfalls and what to avoid
• Using SQL profiles
• Adjusting schema object statistics
• Using stored outlines
• Strategy and techniques for achieving execution plan stability
After completing this part, you will be able to systematically work out which columns
and in which order would give the best results for a workload – there’s no need for
repetitive trial and error!
Systematic indexing
• How to know in advance which indexes would help with data retrieval
performance
• Calculating the best column order for multicolumn indexes
• Understanding lookup overhead of indexes
• Understanding why the index clustering factor matters so much
• Understanding index maintenance overhead
Indexing strategy for high-concurrency updates and insert distribution of “right hand”
indexes (and RAC)
• Reverse-key indexes
• Index column prefixing with instance ID
• Index column prefixing with a deterministic function
Unfortunately Oracle’s Cost Based Optimization process is not perfect; in some cases
because of the Optimizer’s design limitations, sometimes bugs, but often because
incorrectly configured optimizer environment and statistics collection setup.
This part of the seminar provides you the required understanding of CBO internals and
SQL plan execution’s cost estimation process. Armed with this knowledge you will learn
how to put together a strategy for configuring Cost Based Optimizer environment and
statistics collection correctly. We will look into different requirements by different
workloads (such as OLTP vs. DSS systems).
Additionally we will look into how to systematically work out the root causes of CBO
row count and cost misestimates resulting in plan instability and bad performance.