qp opt (08) (Tối ưu hóa truy vấn trong hệ thống dữ liệu chuyên sâu) (Tiếng Anh)

UN
Uni24h
0 次下载
41
0

资料内容

第 3 页

Cost-Based Optimization • Prune the space of plans using heuristics • Estimate cost for remaining plans – Be smart about how you iterate through plans • Pick the plan with least cost Focus on queries with joins

第 4 页

Heuristics for pruning plan space • Predicates as early as possible • Avoid plans with cross products • Only left-deep join trees

第 5 页

Physical Plan Selection Logical Query Plan P1 P2 …. Pn Physical plans C1 C2 …. Cn Costs Pick minimum cost one

第 7 页

Simple Cost Model Cost (R S) = T(R) + T(S) All other operators have 0 cost Note: The simple cost model used for illustration only

第 9 页

Selinger Algorithm • Dynamic Programming based • Dynamic Programming: – General algorithmic paradigm – Exploits “principle of optimality” – Useful reading: • Chapter 16, Introduction to Algorithms, Cormen, Leiserson, Rivest

第 12 页

Principle of Optimality Query: R1 R2 R3 R4 R5 Optimal Plan: R5 R1 R4 R3 R2 Optimal plan for joining R3, R2, R4, R1

第 13 页

Principle of Optimality Query: R1 R2 R3 R4 R5 Optimal Plan: R5 R1 R4 R3 R2 Optimal plan for joining R3, R2, R4

第 14 页

Exploiting Principle of Optimality Query: R1 R2 … Rn R1 R2 R2 R3 R3 R1 Optimal Sub-Optimal for joining R1, R2, R3 for joining R1, R2, R3

第 15 页

Exploiting Principle of Optimality Ri Rj Sub-Optimal R2 for joining R1,…,Rn R3 R1 A sub-optimal sub-plan cannot lead to an optimal plan

第 16 页

Selinger Algorithm: Query: R1 R2 R3 R4 Progress of { R1, R2, R3, R4 } algorithm { R1, R2, R3 } { R1, R2, R4 } { R1, R3, R4 } { R2, R3, R4 } { R1, R2 } { R1, R3 } { R1, R4 } { R2, R3 } { R2, R4 } { R3, R4 } { R1 } { R2 } { R3 } { R4 }

第 17 页

Notation OPT ( { R1, R2, R3 } ): Cost of optimal plan to join R1,R2,R3 T ( { R1, R2, R3 } ): Number of tuples in R1 R2 R3

第 18 页

Selinger Algorithm: OPT ( { R1, R2, R3 } ): OPT ( { R1, R2 } ) + T ( { R1, R2 } ) + T(R3) Min OPT ( { R2, R3 } ) + T ( { R2, R3 } ) + T(R1) OPT ( { R1, R3 } ) + T ( { R1, R3 } ) + T(R2) Note: Valid only for the simple cost model

第 19 页

Selinger Algorithm: Query: R1 R2 R3 R4 Progress of { R1, R2, R3, R4 } algorithm { R1, R2, R3 } { R1, R2, R4 } { R1, R3, R4 } { R2, R3, R4 } { R1, R2 } { R1, R3 } { R1, R4 } { R2, R3 } { R2, R4 } { R3, R4 } { R1 } { R2 } { R3 } { R4 }

第 20 页

Selinger Algorithm: Query: R1 R2 R3 R4 Progress of { R1, R2, R3, R4 } algorithm { R1, R2, R3 } { R1, R2, R4 } { R1, R3, R4 } { R2, R3, R4 } { R1, R2 } { R1, R3 } { R1, R4 } { R2, R3 } { R2, R4 } { R3, R4 } { R1 } { R2 } { R3 } { R4 }

显示前 20 页。下载资料查看完整内容。

评论 (0)

登录 以加入讨论

暂无评论。快来抢沙发吧!