0% found this document useful (0 votes)
107 views17 pages

Schneider 10g Tuning Highlights

This document provides a summary of 10g database tuning highlights presented by Jeremy Schneider. It discusses fundamentals of memory and storage structures, compares rule-based optimization (RBO) vs cost-based optimization (CBO), describes internal database structures and algorithms, tools for monitoring system health and tuning SQL statements, common SQL tuning mistakes, and how the SQL Tuning Advisor can be used to recommend optimizations.

Uploaded by

Manish Aggarwal
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
107 views17 pages

Schneider 10g Tuning Highlights

This document provides a summary of 10g database tuning highlights presented by Jeremy Schneider. It discusses fundamentals of memory and storage structures, compares rule-based optimization (RBO) vs cost-based optimization (CBO), describes internal database structures and algorithms, tools for monitoring system health and tuning SQL statements, common SQL tuning mistakes, and how the SQL Tuning Advisor can be used to recommend optimizations.

Uploaded by

Manish Aggarwal
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 17

10g Tuning Highlights

Presenter

JEREMY SCHNEIDER

[email protected]

Senior Consultant,
ITC Technology Services
OCP, RAC since 2002, Systems Admin
and Developer in previous lives
http://www.ardentperf.com
Fundamentals
 Memory structures
 Storage structures
RBO vs CBO
RBO vs CBO
1. Single Row by Rowid  Only single column indexes are ever merged.
2. Single Row by Cluster Join  If all columns in an index are specified in the WHERE
3. Single Row by Hash Cluster Key clause, that index will be used in preference to other
with Unique or Primary Key indexes for which some columns are referenced.
4. Single Row by Unique or Primary
 If multiple indexes can be applied to a WHERE clause,
Key and they all have an equal number of columns specified,
only the index created last will be used.
5. Clustered Join  If multiple columns of an index are being accessed with
6. Hash Cluster Key an = operator, that will override other operators such as
7. Indexed Cluster Key LIKE or BETWEEN. Two ='s will override two ='s and a
8. Composite Index LIKE.
9. Single-Column Indexes  A higher percentage of columns accessed will override a
lower percentage of columns accessed. So generally,
10. Bounded Range Search on the optimizer will choose to use the index from which
Indexed Columns you specify the highest percentage of columns.
11. Unbounded Range Search on However, as stated previously, all columns specified in a
Indexed Columns unique or primary key index will override the use of all
12. Sort Merge Join other indexes.
13. MAX or MIN of Indexed Column  The RBO uses rules to select the driving table.
14. ORDER BY on Indexed Column  If a WHERE clause has a column that is the leading
15. Full Table Scan column on any index, the rule-based optimizer will use
that index. The exception is if a function is placed on the
leading index column in the WHERE clause.

*Check out http://www.oreilly.com/catalog/orsqltunpr/chapter/excerpt.html


RBO vs CBO
 Based on advanced mathematics
and statistics
 Default 80,000 permutations
(optimizer_max_permutations)
RBO vs CBO
SQL> desc all_tables
Name Null? Type
-------------------------- -------- ------------
...
NUM_ROWS NUMBER
BLOCKS NUMBER
EMPTY_BLOCKS NUMBER SQL> desc all_tab_columns
AVG_SPACE NUMBER Name Null? Type
CHAIN_CNT NUMBER -------------------------- -------- ------------
AVG_ROW_LEN NUMBER ...
... NUM_DISTINCT NUMBER
SAMPLE_SIZE NUMBER LOW_VALUE RAW(32)
LAST_ANALYZED DATE HIGH_VALUE RAW(32)
... DENSITY NUMBER
GLOBAL_STATS VARCHAR2(3) NUM_NULLS NUMBER
USER_STATS VARCHAR2(3) NUM_BUCKETS NUMBER
... LAST_ANALYZED DATE
SAMPLE_SIZE NUMBER
...
GLOBAL_STATS VARCHAR2(3)
USER_STATS VARCHAR2(3)
AVG_COL_LEN NUMBER
...
HISTOGRAM VARCHAR2(15)
Internal Structures & Algorithms
 Latches
 Enqueues
 Locks
 Pins

 Bitmaps
 Linked Lists
 Hash Maps

 Caching
 Sorting (opt,single,multi)
System Health
 Statspack Reports or AWR Reports (10g)
 DBControl
SQL Statement Tuning Methodology
 Don’t guess! Set goals and have a plan.

 Investigate scientifically. Oracle is very highly instrumented.


SQL Statement Top 10 Mistakes
1. Bad Connection Management
2. Bad Use of Cursors in the Shared Pool
3. Bad SQL
4. Nonstandard Initialization Parameters
5. Datafiles layed out poorly for I/O
6. Too few or too small redo logs (checkpoint errors)
7. Serialization – shortage of freelists, transactions slots or rollback segs
8. Inefficient full table scans
9. Large amount of recursive (SYS) SQL
10. Deployment/migration errors (e.g. missing indexes)
SQL Statement Tuning
What can cause SQL execution to change?

1. Change in text of SQL statement (including hints)


2. Change in schema (indexes, parallel declarations, etc)
3. Change in object statistics
4. Change in system statistics
5. Change in system (init/spfile) or session parameters
6. Manipulation of Stored Outline or SQL Profile
7. Change in CBO code (i.e. upgrade or patch)
10g Tools for SQL Statement Tuning
 Explain plan (DBMS_XPLAN)
 Runtime Statistics (V$SESSTAT, V$SYSSTAT, V$PGASTAT)
 SQL Advisor
 SQLTrace (10046) and tkprof
 CBO Trace (10059)
 Stored Outlines

Can use SQLPlus or DBControl


SQL Tuning Advisor
 SQL Tuning Advisor in Oracle 10g

Evaluate
Implement Recommendations

Workload DBA DBA


Generate
Recommendations

Animation from Oracle


one hour
DBA

ADDM Invoke
Advisor SQL Tuning
AWR SQL Tuning Advisor
Candidates
SQL Tuning Advisor
1. Create Index
2. Rewrite SQL (UNION ALL, NOT EXISTS, etc)
3. Gather Stats (stale or missing)
4. Create SQL Profile (correct cardinality or selectivity estimates,
optimizer mode – only in comprehensive mode, not in limited mode)
Where to Learn More
 Documentation – tahiti.oracle.com
 Metalink and OTN
 Local User Group
 Online Community – Oracle Forums, oracle-l, c.d.o.s (usenet)
 Websites – asktom, oracle-base, orafaq, dizwell, jlcomp
 Blogs – Kyte, Lewis, Closson, Rittman
 Try things out on your own!
Q&A
Questions, comments, suggestions?

You might also like