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 lượt tải
41
0

Nội dung tài liệu

Trang 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

Trang 4

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

Trang 5

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

Trang 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

Trang 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

Trang 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

Trang 13

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

Trang 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

Trang 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

Trang 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 }

Trang 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

Trang 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

Trang 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 }

Trang 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 }

Hiển thị 20 trang đầu. Tải tài liệu để xem đầy đủ.

Bình luận (0)

Đăng nhập để tham gia bình luận

Chưa có bình luận nào. Hãy là người đầu tiên!