[中文]
Author:
fuyuncat
Source:
www.HelloDBA.com
Date:
2012-09-30 01:31:02
Oracle SQL Optimizing and Tuning Technologies
ORACLE SQL OPTIMIZING AND TUNING TECHNOLOGIES 1Preface 7Abstraction 8SECTION 1 EXECUTION PLAN 10Chapter 1. Generate and Display Execution Plan 101.1 Gnerate Execution Plan 111.2 Display Execution Plan 121.2.1 Using SQL Query 121.2.2 Using DBMS_XPLAN 131.2.3 Using AUTOTRACE 191.2.4 Other Approaches 20Chapter 2. Read Execution Plan 222.1 Basic Information in Execution Plan 222.2 Internal Functions and Execution Plan Operations 232.3 Data In Exectuion Plan 252.4 Operations in Execution Plan 262.4.1 Statement(DDL&DML) Operations 272.4.2 Access Path Operations 302.4.3 Bitmap Operations 462.4.4 Sort Operations 512.4.5 Join Operations 552.4.6 Hierarchy Query Operations 682.4.7 View Operations 712.4.8 Data Set Operations 722.4.9 Partitions Operations 752.4.10 Parallel Query Operations 822.4.11 Aggregate Operations 952.4.12 Analytic Operations 962.4.13 SQL Model Operation 992.4.14 Data and Object Management Operations 1022.4.15 Others 1052.5 Other Information 1112.5.1 Query Block and Alias 1112.5.2 Outline Data 1112.5.3 Peeked Binds 1122.5.4 Remote SQL Information 1132.5.5 Note 113SECTION 2 SQLOPTIMIZING TECHNOLOGIES 113Chapter 3. Query Transformation 1143.1 Heuristic Transformation 1153.1.1 Simple View Merge 1153.1.2 Subquery Unnesting 1193.1.3 Push Subquery 1243.1.4 Old Join Predicate Push-Dowd 1263.1.5 Filter Push-Down 1283.1.6 Predicate Move Around 1293.1.7 OR Expansion 1303.1.8 Materialized View Re-write 1313.1.9 Set Join Conversion 1323.1.10 Gernate Predicate from Constraint 1333.1.11 Star Transformation 1343.1.12 Order By Elimination 1363.1.13 Distinct Elimination 1373.1.14 Table Elimination 1373.1.15 Subquery Coalesce 1403.1.16 Common Subexpression elimination 1413.1.17 Count Convertion 1423.1.18 Evaluation of Expressions and Conditions 1433.1.19 Aggregate Subquery Elimination 1483.1.20 Distinct Aggregate Transformation 1493.1.21 select list pruning,SLP 1513.1.22 Distinct Elimination 1513.1.23 Distinct Push Down 1523.1.24 Grouping Set To Union 1533.1.25 Grouping Set Rewrite 1533.1.26 Group Pruning 1543.1.27 Outer Join Elimination 1563.1.28 Native Full Outer Join 1563.1.29 Lateral View 1583.2 Cost Based Transformationb 1613.2.1 Complex View Merging 1613.2.2 Join Predicate Push-Down 1623.2.3 Predicate Pull Up 1643.2.4 Group By Placement 1653.2.5 Table Expansion 1663.2.6 Join factorization 1673.2.7 Distinct Placement 1693.2.8 With Subquery Tranformation 170Chapter 4. Statistics Data 1704.1 System Statistics Data 1714.1.1 Gather System Statistics Data 1714.1.2 Manager System Statistics Data 1734.1.3 Flexible Management 1774.1.4 Manage Parameters 1784.1.5 Manage Preferences 1804.2 Object Statistics Data 1834.2.1 Table Statistics Data 1834.2.2 Index Statistics Data 1844.2.3 Column Statistics Data 1844.2.4 Extended Statistics Data 1854.2.5 Manage Object Statistics Data 1864.2.6 Pedning Statistics Data 1964.3 Object Statistics Data Gathering Analysis 1974.3.1 Table Statistics Data Gathering and Calculating 1984.3.2 Column Statistics Data Gathering and Calculating 2004.3.3 Histogram Gathering and Calculating 2054.3.4 Index Statistics Data Gathering and Calculating 216Section 5. Execution Plan Cost Estimate 2185.1 Optimizer Cost Model 2195.2 Fundamental Cost Formula 2205.3 Calculate Selectivity 2225.3.1 Single Filter Condition 2225.3.2 Bind Variable without Peeking 2225.3.3 Peeked Binds without Histogram 2235.3.4 Calculate with Histogram 2235.3.5 Combined Filter 2275.4 Cost of Multiple Data Block Read Operations 2285.4.1 Cost Model 2285.4.2 Calculate IO Cost 2305.4.3 Calculate CPU Cost 2325.4.4 Calculate Other Data 2385.4.5 Cost Calculation Demo of Full Table Scan 2385.5 Cost of Parallel Query 2475.5.1 Calculate IO Cost 2475.5.2 Calculate CPU Cost 2495.6 Cost of Single Data Block Read Operations 2495.6.1 Calculate IO Cost 2505.6.2 Calculate CPU Cost 2535.6.3 Cost Calculation Demo of Single Data Block Read Operation 2555.7 Cost of Sort Operations 2595.7.1 Pass Data to Disk or Not 2595.7.2 Calculate IO Cost 2605.7.3 Calculate CPU Cost 2615.7.4 Cost Calculation Demo of Sort 2625.8 Cost of Join Operations 2665.8.1 Join Selectivity 2665.8.2 Calculate Nested-Loop Join Cost 2675.8.3 Calculate Sort-Merge Join Cost 2725.8.4 Calculate Hash Join Cost 2755.9 Cost of Prarllel Join Operations 2825.9.1 Calculate IO Cost 2835.9.2 Calculate CPU Cost 2845.9.3 Cost Calculation Demo of Prarllel Join Operation 284SECTION 3 SQL TUNING TECHNOLOGIES 288Chapter 6. SQL Run-Time Performance Statistics Data 2886.1 Performance Statistics Data 2886.1.1 session logical reads 2886.1.2 consistent gets 2896.1.3 consistent gets direct 2896.1.4 consistent gets from cache 2906.1.5 consistent changes 2916.1.6 db block gets 2916.1.7 db block gets direc 2926.1.8 db block gets from cache 2936.1.9 db block changes 2936.1.10 physical reads 2946.1.11 physical reads cache 2946.1.12 physical reads cache prefetch 2956.1.13 physical reads direct 2956.1.14 physical writes 2956.1.15 physical writes from cache 2956.1.16 physical writes direct 2956.1.17 sorts (memory) 2956.1.18 sorts (disk) 2966.1.19 sorts (rows) 2976.1.20 recursive calls 2976.2 Run-Time Performance Analysis 2976.2.1 Logical Reads Analysis 2976.2.2 Physical Reads Analysis 3336.2.3 Recursive Calls 394Chapter 7. Oracle Tuning Technologies 3957.1 Stored Outline 3967.1.1 What is Stored Outline 3967.1.2 Generate Stored Outline 3977.1.3 Manage Stored Outline 3997.1.4 Use Stored Outline 4007.2 SQL Plan Management 4027.2.1 Generate and Add Plan Baseline 4027.2.2 Evolve Historical Execution Plan 4137.2.3 Optimizer Choose Execution Plan from Plan Baseline 4147.3 Oracle SQL Tuning Advisor 4167.3.1 Create Tuning Task 4167.3.2 Parametes of SQL Advisor 4177.3.3 SQL Tuning Analysis 4187.4 SQL Performance Analyzer 4297.4.1 The Procedure of Performance Analyzing 4297.4.2 Demostration SQL Performance Analyzing 4317.5 SQL Access Advisor 4337.5.1 Procedure of the Advisor Advise New Index 4337.5.2 Use SQL Access Advisor 437Chapter 8. Quick SQL Tuning 4438.1 Check Statistics Data 4438.2 Identify Potential Problem from Execution Plan 4468.2.1 Multiple Execution Plan 4468.2.2 Note from Execution Plan 4498.2.3 High Risk Operations 4508.2.4 Predicate Information 4548.2.5 Check Outline Data and Optimizing Environment 4568.3 Physical Design Tuning 4568.3.1 Index 4568.3.2 Partition 4578.3.3 Materialized View 4588.3.4 Constratins 458Appendix: SQL HINT Usage and Real Cases 458Not End 535