| Preface |
|
xv | |
|
|
|
1 | (10) |
|
Another Book About SQL Performance! |
|
|
1 | (2) |
|
|
|
3 | (1) |
|
|
|
4 | (4) |
|
Myth 1: No More Than Five Index Levels |
|
|
5 | (1) |
|
Myth 2: No More Than Six Indexes per Table |
|
|
6 | (1) |
|
Myth 3: Volatile Columns Should Not Be Indexed |
|
|
6 | (1) |
|
|
|
7 | (1) |
|
|
|
7 | (1) |
|
|
|
8 | (3) |
|
Table and Index Organization |
|
|
11 | (18) |
|
|
|
11 | (1) |
|
|
|
12 | (1) |
|
|
|
12 | (1) |
|
|
|
13 | (1) |
|
|
|
13 | (1) |
|
Buffer Pools and Disk I/Os |
|
|
13 | (7) |
|
Reads from the DBMS Buffer Pool |
|
|
14 | (1) |
|
Random I/O from Disk Drives |
|
|
14 | (1) |
|
Reads from the Disk Server Cache |
|
|
15 | (1) |
|
Sequential Reads from Disk Drives |
|
|
16 | (1) |
|
|
|
16 | (3) |
|
Assisted Sequential Reads |
|
|
19 | (1) |
|
Synchronous and Asynchronous I/Os |
|
|
19 | (1) |
|
|
|
20 | (1) |
|
|
|
21 | (8) |
|
|
|
21 | (1) |
|
|
|
22 | (1) |
|
|
|
23 | (1) |
|
|
|
23 | (1) |
|
|
|
23 | (1) |
|
|
|
24 | (1) |
|
Alternatives to B-tree Indexes |
|
|
25 | (1) |
|
|
|
26 | (3) |
|
|
|
29 | (18) |
|
|
|
29 | (1) |
|
|
|
30 | (1) |
|
Optimizers and Access Paths |
|
|
30 | (7) |
|
Index Slices and Matching Columns |
|
|
31 | (1) |
|
Index Screening and Screening Columns |
|
|
32 | (1) |
|
|
|
33 | (1) |
|
|
|
34 | (1) |
|
Helping the Optimizer (Statistics) |
|
|
34 | (1) |
|
Helping the Optimizer (Number of FETCH Calls) |
|
|
35 | (1) |
|
When the Access Path Is Chosen |
|
|
36 | (1) |
|
|
|
37 | (5) |
|
Filter Factors for Compound Predicates |
|
|
37 | (2) |
|
Impact of Filter Factors on Index Design |
|
|
39 | (3) |
|
Materializing the Result Rows |
|
|
42 | (2) |
|
|
|
42 | (1) |
|
Alternative 1: FETCH Call Materializes One Result Row |
|
|
43 | (1) |
|
Alternative 2: Early Materialization |
|
|
44 | (1) |
|
What Every Database Designer Should Remember |
|
|
44 | (1) |
|
|
|
44 | (3) |
|
Deriving the Ideal Index for a Select |
|
|
47 | (16) |
|
|
|
47 | (1) |
|
Basic Assumptions for Disk and CPU Times |
|
|
48 | (1) |
|
|
|
48 | (1) |
|
Three-Star Index---The Ideal Index for a Select |
|
|
49 | (5) |
|
How the Stars Are Assigned |
|
|
50 | (2) |
|
Range Predicates and a Three-Star Index |
|
|
52 | (2) |
|
Algorithm to Derive the Best Index for a Select |
|
|
54 | (2) |
|
|
|
54 | (1) |
|
|
|
55 | (1) |
|
Sorting Is Fast Today---Why Do We Need Candidate B? |
|
|
55 | (1) |
|
Ideal Index for Every Select? |
|
|
56 | (2) |
|
Totally Superfluous Indexes |
|
|
57 | (1) |
|
Practically Superfluous Indexes |
|
|
57 | (1) |
|
Possibly Superfluous Indexes |
|
|
58 | (1) |
|
Cost of an Additional Index |
|
|
58 | (4) |
|
|
|
58 | (1) |
|
|
|
59 | (2) |
|
|
|
61 | (1) |
|
|
|
62 | (1) |
|
|
|
62 | (1) |
|
|
|
63 | (24) |
|
Detection of Inadequate Indexing |
|
|
63 | (1) |
|
|
|
63 | (2) |
|
|
|
64 | (1) |
|
Quick Upper-Bound Estimate (QUBE) |
|
|
65 | (10) |
|
|
|
65 | (1) |
|
|
|
66 | (1) |
|
|
|
67 | (2) |
|
|
|
69 | (1) |
|
|
|
70 | (1) |
|
QUBE Examples for the Main Access Types |
|
|
71 | (4) |
|
Cheapest Adequate Index or Best Possible Index: Example 1 |
|
|
75 | (7) |
|
Basic Question for the Transaction |
|
|
78 | (1) |
|
Quick Upper-Bound Estimate for the Transaction |
|
|
78 | (1) |
|
Cheapest Adequate Index or Best Possible Index |
|
|
79 | (1) |
|
Best Index for the Transaction |
|
|
79 | (1) |
|
Semifat Index (Maximum Index Screening) |
|
|
80 | (1) |
|
|
|
80 | (2) |
|
Cheapest Adequate Index or Best Possible Index: Example 2 |
|
|
82 | (4) |
|
Basic Question and QUBE for the Range Transaction |
|
|
82 | (1) |
|
Best Index for the Transaction |
|
|
83 | (1) |
|
Semifat Index (Maximum Index Screening) |
|
|
84 | (1) |
|
|
|
85 | (1) |
|
|
|
86 | (1) |
|
Factors Affecting the Index Design Process |
|
|
87 | (18) |
|
I/O Time Estimate Verification |
|
|
87 | (1) |
|
Multiple Thin Index Slices |
|
|
88 | (3) |
|
Simple Is Beautiful (and Safe) |
|
|
90 | (1) |
|
|
|
91 | (3) |
|
|
|
91 | (1) |
|
Or Operator and Boolean Predicates |
|
|
92 | (1) |
|
|
|
93 | (1) |
|
|
|
94 | (2) |
|
Filter Factor Pitfall Example |
|
|
96 | (6) |
|
Best Index for the Transaction |
|
|
99 | (1) |
|
Semifat Index (Maximum Index Screening) |
|
|
100 | (1) |
|
|
|
101 | (1) |
|
|
|
101 | (1) |
|
|
|
102 | (3) |
|
|
|
105 | (30) |
|
|
|
105 | (1) |
|
Explain Describes the Selected Access Paths |
|
|
106 | (2) |
|
Full Table Scan or Full Index Scan |
|
|
106 | (1) |
|
|
|
106 | (1) |
|
|
|
107 | (1) |
|
DBMS-Specific Explain Options and Restrictions |
|
|
108 | (1) |
|
Monitoring Reveals the Reality |
|
|
108 | (3) |
|
Evolution of Performance Monitors |
|
|
109 | (2) |
|
LRT-Level Exception Monitoring |
|
|
111 | (12) |
|
Averages per Program Are Not Sufficient |
|
|
111 | (1) |
|
Exception Report Example: One Line per Spike |
|
|
111 | (1) |
|
|
|
112 | (2) |
|
Promising and Unpromising Culprits |
|
|
114 | (1) |
|
|
|
114 | (2) |
|
|
|
116 | (4) |
|
|
|
120 | (1) |
|
|
|
121 | (2) |
|
Finding the Slow SQL Calls |
|
|
123 | (1) |
|
Call-Level Exception Monitoring |
|
|
123 | (8) |
|
|
|
126 | (3) |
|
|
|
129 | (2) |
|
|
|
131 | (1) |
|
DBMS-Specific Monitoring Issues |
|
|
131 | (2) |
|
|
|
132 | (1) |
|
|
|
133 | (2) |
|
|
|
135 | (50) |
|
|
|
135 | (1) |
|
|
|
136 | (3) |
|
Example 8.1: Customer Outer Table |
|
|
137 | (1) |
|
Example 8.2: Invoice Outer Table |
|
|
138 | (1) |
|
Impact of Table Access Order on Index Design |
|
|
139 | (19) |
|
|
|
140 | (3) |
|
|
|
143 | (6) |
|
|
|
149 | (4) |
|
Ideal Indexes with One Screen per Transaction Materialized |
|
|
153 | (4) |
|
Ideal Indexes with One Screen per Transaction Materialized and FF Pitfall |
|
|
157 | (1) |
|
Basic Join Question (BJQ) |
|
|
158 | (3) |
|
Conclusion: Nested-Loop Join |
|
|
160 | (1) |
|
Predicting the Table Access Order |
|
|
161 | (2) |
|
Merge Scan Joins and Hash Joins |
|
|
163 | (7) |
|
|
|
163 | (1) |
|
Example 8.3: Merge Scan Join |
|
|
163 | (2) |
|
|
|
165 | (1) |
|
Program C: MS/HJ Considered by the Optimizer (Current Indexes) |
|
|
166 | (1) |
|
|
|
167 | (3) |
|
Nested-Loop Joins Versus MS/HJ and Ideal Indexes |
|
|
170 | (1) |
|
Nested-Loop Joins Versus MS/HJ |
|
|
170 | (1) |
|
|
|
171 | (1) |
|
Joining More Than Two Tables |
|
|
171 | (3) |
|
Why Joins Often Perform Poorly |
|
|
174 | (1) |
|
|
|
174 | (1) |
|
Optimizer May Choose the Wrong Table Access Order |
|
|
175 | (1) |
|
|
|
175 | (1) |
|
Designing Indexes for Subqueries |
|
|
175 | (1) |
|
Designing Indexes for Unions |
|
|
176 | (1) |
|
Table Design Considerations |
|
|
176 | (7) |
|
|
|
176 | (4) |
|
|
|
180 | (3) |
|
|
|
183 | (2) |
|
|
|
185 | (10) |
|
|
|
185 | (2) |
|
Indexes on Dimension Tables |
|
|
187 | (1) |
|
Huge Impact of the Table Access Order |
|
|
188 | (2) |
|
|
|
190 | (2) |
|
|
|
192 | (3) |
|
|
|
195 | (8) |
|
|
|
195 | (1) |
|
|
|
195 | (4) |
|
Index ANDing with Query Tables |
|
|
197 | (1) |
|
Multiple Index Access and Fact Tables |
|
|
198 | (1) |
|
Multiple Index Access with Bitmap Indexes |
|
|
198 | (1) |
|
|
|
199 | (1) |
|
|
|
200 | (1) |
|
|
|
201 | (2) |
|
Indexes and Reorganization |
|
|
203 | (28) |
|
Physical Structure of a B-Tree Index |
|
|
203 | (1) |
|
How the DBMS Finds an Index Row |
|
|
204 | (1) |
|
What Happens When a Row Is Inserted? |
|
|
205 | (1) |
|
Are Leaf Page Splits Serious? |
|
|
206 | (2) |
|
When Should an Index Be Reorganized? |
|
|
208 | (8) |
|
|
|
208 | (8) |
|
|
|
216 | (2) |
|
|
|
218 | (1) |
|
Example: Order-Sensitive Batch Job |
|
|
219 | (4) |
|
Table Disorganization (with a Clustering Index) |
|
|
222 | (1) |
|
Table Disorganization (Without Clustering Index Starting with CNO) |
|
|
223 | (1) |
|
Table Rows Stored in Leaf Pages |
|
|
223 | (2) |
|
|
|
223 | (1) |
|
|
|
224 | (1) |
|
Cost of Index Reorganization |
|
|
225 | (1) |
|
|
|
226 | (1) |
|
|
|
227 | (4) |
|
DBMS-Specific Indexing Restrictions |
|
|
231 | (6) |
|
|
|
231 | (1) |
|
|
|
231 | (1) |
|
Total Length of the Index Columns |
|
|
232 | (1) |
|
|
|
232 | (1) |
|
Number of Indexes per Table |
|
|
232 | (1) |
|
|
|
232 | (1) |
|
|
|
232 | (1) |
|
|
|
233 | (1) |
|
DBMS Index Creation Examples |
|
|
234 | (3) |
|
DBMS-Specific Indexing Options |
|
|
237 | (8) |
|
|
|
237 | (1) |
|
|
|
237 | (1) |
|
Additional Index Columns After the Index Key |
|
|
238 | (2) |
|
Constraints to Enforce Uniqueness |
|
|
240 | (1) |
|
DBMS Able to Read an Index in Both Directions |
|
|
240 | (1) |
|
|
|
241 | (1) |
|
|
|
241 | (1) |
|
|
|
242 | (1) |
|
|
|
243 | (1) |
|
Data-Partitioned Secondary Indexes |
|
|
243 | (1) |
|
|
|
244 | (1) |
|
Optimizers Are Not Perfect |
|
|
245 | (22) |
|
|
|
245 | (1) |
|
Optimizers Do Not Always See the Best Alternative |
|
|
246 | (6) |
|
Matching and Screening Problems |
|
|
246 | (1) |
|
|
|
247 | (3) |
|
|
|
250 | (1) |
|
Unnecessary Table Touches |
|
|
251 | (1) |
|
Optimizers' Cost Estimates May Be Very Wrong |
|
|
252 | (7) |
|
Range Predicates with Host Variables |
|
|
252 | (1) |
|
|
|
253 | (2) |
|
|
|
255 | (1) |
|
Cautionary Tale of Partial Index Keys |
|
|
256 | (3) |
|
|
|
259 | (6) |
|
|
|
259 | (2) |
|
|
|
261 | (1) |
|
Helping the Optimizer with Estimate-Related Problems |
|
|
261 | (4) |
|
Do Optimizer Problems Affect Index Design? |
|
|
265 | (1) |
|
|
|
265 | (2) |
|
Additional Estimation Considerations |
|
|
267 | (22) |
|
Assumptions Behind the QUBE Formula |
|
|
267 | (1) |
|
Nonleaf Index Pages in Memory |
|
|
268 | (4) |
|
|
|
268 | (1) |
|
Impact of the Disk Server Read Cache |
|
|
269 | (1) |
|
|
|
270 | (2) |
|
|
|
272 | (1) |
|
|
|
272 | (1) |
|
When the Actual Response Time Can Be Much Shorter Than the QUBE |
|
|
272 | (6) |
|
Leaf Pages and Table Pages Remain in the Buffer Pool |
|
|
273 | (2) |
|
Identifying These Cheap Random Touches |
|
|
275 | (1) |
|
|
|
275 | (3) |
|
Assisted Sequential Reads |
|
|
278 | (1) |
|
Estimating CPU Time (CQUBE) |
|
|
278 | (4) |
|
CPU Time per Sequential Touch |
|
|
278 | (1) |
|
CPU Time per Random Touch |
|
|
279 | (2) |
|
|
|
281 | (1) |
|
|
|
282 | (1) |
|
|
|
282 | (7) |
|
|
|
283 | (1) |
|
Nested-Loop Join (and Denormalization) or MS/HJ |
|
|
283 | (3) |
|
Merge Scan and Hash Join Comparison |
|
|
286 | (1) |
|
|
|
287 | (1) |
|
|
|
288 | (1) |
|
Organizing the Index Design Process |
|
|
289 | (6) |
|
|
|
289 | (1) |
|
Computer-Assisted Index Design |
|
|
290 | (2) |
|
Nine Steps Toward Excellent Indexes |
|
|
292 | (3) |
|
|
|
295 | (2) |
|
|
|
297 | (8) |
|
|
|
297 | (2) |
|
|
|
299 | (6) |
| Index |
|
305 | |