O-OPT Optimizer Workshop - Trivadis
O-OPT Optimizer Workshop - Trivadis
O-OPT Optimizer Workshop - Trivadis
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
O-<strong>OPT</strong><br />
<strong>Optimizer</strong> <strong>Workshop</strong><br />
<strong>Trivadis</strong> AG<br />
Christian Antognini<br />
Dani Schnider<br />
Reinhard Bauer<br />
June 2008<br />
Vers. 3.2.3
This course documentation is based on:<br />
Copyright © <strong>Trivadis</strong> AG, 2001-2008, all rights reserved. Printed in Switzerland.<br />
Limited rights.<br />
Neither this documentation nor any part of it may be copied or reproduced in any form or for any<br />
reason without the prior written consent of <strong>Trivadis</strong> AG<br />
The information contained in this documentation is subject to change without notice. Should you<br />
find any errors in this course documentation, please inform:<br />
<strong>Trivadis</strong> AG<br />
Europa-Strasse 5<br />
CH-8152 Glattbrugg-Zurich<br />
or E-mail to<br />
training@trivadis.com<br />
<strong>Trivadis</strong> AG assumes no responsibility for any errors that may appear in this course documentation.<br />
Oracle7, Oracle8, Oracle8i, Oracle9i, Oracle10g, Oracle11g Oracle Designer, Oracle Developer,<br />
Oracle Applications, Oracle Forms, Oracle Reports, Oracle Browser, Oracle Data Query, Oracle<br />
Human Resources, Oracle Personnel, PL/SQL, Pro*C, Oracle Graphics, Oracle Generator are<br />
Trademarks of Oracle Corporation.<br />
Microsoft and MS-DOS are registered trademarks and Windows is a trademark of Microsoft<br />
Corporation.
Table of Contents<br />
1 Introduction 1-1<br />
2 Cost-Based <strong>Optimizer</strong> 2-1<br />
2.1 How the CBO Works 2-2<br />
2.2 Object Statistics 2-9<br />
2.3 Dynamic Sampling 2-17<br />
2.4 System Statistics 2-24<br />
2.5 <strong>Optimizer</strong> Hints 2-29<br />
3 Execution Plans 3-1<br />
3.1 Explain Plan 3-2<br />
3.2 Auto Trace 3-11<br />
3.3 GUI TOOLS 3-16<br />
3.4 DBMS_XPLAN.DISPLAY_CURSOR 3-19<br />
3.5 <strong>Trivadis</strong> Explainer 3-23<br />
4 <strong>Workshop</strong> I 4-1<br />
4.1 Tasks 4-3<br />
4.2 Solutions 4-8<br />
5 Table Scans 5-1<br />
5.1 Full Table Scan 5-2<br />
5.2 Compressed Tables 5-10<br />
5.3 Temporary Tables 5-14<br />
5.4 Hints 5-18<br />
6 B-tree Indexes 6-1<br />
6.1 Concept of B-tree Indexes 6-2<br />
6.2 Index Unique/Range Scan 6-5<br />
6.3 Concatenated Index 6-10<br />
6.4 Special Index Scans 6-16<br />
6.5 Index Creation 6-22<br />
6.6 Index Costing 6-25<br />
6.7 Hints 6-35<br />
Copyright© <strong>Trivadis</strong> AG Table of Contents 3
7 <strong>Workshop</strong> II 7-1<br />
7.1 Tasks 7-2<br />
7.2 Solutions 7-7<br />
8 Bitmap Indexes 8-1<br />
8.1 Concept of Bitmap Indexes 8-2<br />
8.2 Bitmap Conversion of B-tree Indexes 8-8<br />
8.3 Bitmap Indexes and DML Statements 8-11<br />
9 SQL Trace and tkprof 9-1<br />
9.1 Overview 9-2<br />
9.2 SQL Trace 9-6<br />
9.3 tkprof 9-11<br />
10 <strong>Workshop</strong> III 10-1<br />
10.1 Tasks 10-2<br />
10.2 Solutions 10-6<br />
11 Join Methods 11-1<br />
11.1 Optimizing Joins 11-2<br />
11.2 Nested Loop Join 11-5<br />
11.3 Sort Merge Join 11-12<br />
11.4 Hash Join 11-16<br />
11.5 Outer Join 11-21<br />
11.6 Index Join 11-28<br />
11.7 Join Costing 11-32<br />
11.8 Hints 11-40<br />
12 Subqueries 12-1<br />
12.1 Subqueries and Joins 12-2<br />
12.2 Correlated Subqueries 12-5<br />
12.3 Uncorrelated Subqueries 12-8<br />
12.4 Subquery Factoring Clause 12-12<br />
13 <strong>Workshop</strong> IV 13-1<br />
13.1 Tasks 13-2<br />
13.2 Solutions 13-7<br />
4 Copyright© <strong>Trivadis</strong> AG
14 DBMS_STATS 14-1<br />
14.1 Automatic Statistics Gathering 14-2<br />
14.2 Gathering Object Statistics 14-4<br />
14.3 Gatherin System Statistics 14-18<br />
14.4 Managing and Transferring Statistics 14-24<br />
15 Views 15-1<br />
15.1 Mergeable and Non-Mergeable Views 15-2<br />
15.2 Predicate Pushing 15-10<br />
15.3 Complex View Merging 15-13<br />
15.4 Hints 15-17<br />
15.5 Query Block Specification 15-22<br />
16 Advanced Index Concepts 16-1<br />
16.1 Index-organized Table 16-2<br />
16.2 Function-based Index 16-12<br />
16.3 Bitmap Index Concepts 16-20<br />
17 <strong>Workshop</strong> V 17-1<br />
17.1 Tasks 17-2<br />
17.2 Solutions 17-8<br />
18 Materialized Views 18-1<br />
18.1 Concept 18-2<br />
18.2 DDL 18-10<br />
18.3 Refresh 18-15<br />
18.4 Query Rewrite 18-29<br />
18.5 Explain Procedures 18-38<br />
19 DML Statements 19-1<br />
19.1 INSERT Statements 19-2<br />
19.2 DELETE Statements 19-10<br />
19.3 UPDATE Statements 19-14<br />
19.4 MERGE Statements 19-17<br />
20 Partitioning 20-1<br />
20.1 Reasons for Partitioning 20-2<br />
20.2 Partitioning Methods 20-4<br />
20.3 Partition Pruning 20-11<br />
20.4 Partition-Wise Join 20-19<br />
Copyright© <strong>Trivadis</strong> AG Table of Contents 5
20.5 Index Partitioning 20-25<br />
20.6 Statistics 20-32<br />
21 <strong>Workshop</strong> VI 21-1<br />
21.1 Tasks 21-2<br />
21.2 Solutions 21-5<br />
22 Plan Stability and SQL Profiles 22-1<br />
22.1 Plan Stability 22-2<br />
22.2 Automatic Tuning <strong>Optimizer</strong> 22-6<br />
22.3 Why SQL Profiles? 22-11<br />
22.4 Management and Use 22-14<br />
22.5 Requirements 22-25<br />
22.6 Data Dictionary 22-27<br />
22.7 Sample Cases 22-30<br />
23 Data Model 23-1<br />
24 Index 24-1<br />
6 Copyright© <strong>Trivadis</strong> AG