Introduction to the LHCb masterclass exercise V. V. Gligorov, CERN.
Query Optimization: Exercise · 2017. 11. 27. · I node costs: C out of the join v 12 500 23 50 v...
Transcript of Query Optimization: Exercise · 2017. 11. 27. · I node costs: C out of the join v 12 500 23 50 v...
![Page 1: Query Optimization: Exercise · 2017. 11. 27. · I node costs: C out of the join v 12 500 23 50 v 14 5000 v 34 1000 5 0:5 0:5 50 10 1 2 Query Optimization: Exercise Session 6 November](https://reader036.fdocuments.us/reader036/viewer/2022071301/609dd6ee5426c42b823cc545/html5/thumbnails/1.jpg)
Query Optimization ExerciseSession 6
Bernhard Radke
November 27 2017
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP)
Maximum Value Precedence (MVP) [1]
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Weighted Directed Join Graph (WDJG)
Weighted Directed Join Graph (WDJG)
R1
1000
R2
100
R4
100
R3
500
0005
0001
002
005
Query graph to WDJG = (V EpEv )
I nodes V = joins
I physical edges Ep between rdquoadjacentrdquojoins (share one relation)
I virtual edges Ev everywhere else
I R(v) relations participating in join v
I Observation every spanning tree in theWDJG leads to a join tree
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Weighted Directed Join Graph (WDJG)
R1
1000
R2
100
R4
100
R3
500
0005
0001
002
005
v12
500
v23
50
v14
5000
v34
1000
5
05
05 5
50
10
01 2
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Weighted Directed Join Graph (WDJG)
Weights and Costs
I edge weights
wuv =
| u ||R(u)capR(v)| if (u v) isin Ep
1 if (u v) isin Ev
I node costs Cout of the join
v12
500v23
50
v14
5000
v34
1000
5
05
05 5
50
10
01 2
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Effective Spanning Tree (EST)
Effective Spanning Tree (EST)
Three conditions
1 EST is binary
2 For every non-leaf node vi for every edge vj rarr vi there is a common base relationbetween vi and the subtree with the root vj
3 For every node vi = R on S with two incoming edges vk rarr vi and vj rarr viI R or S can be present at most in one of the subtrees vk or vjI unless the subtree vj (or vk) contains both R and S
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) MVP - informally
MVP - informally
Construct an EST in two steps
Step 1 - Choose an edge to reduce the cost of an expensive operation
I Start with the most expensive nodeI Find the incoming edge that reduces the cost the mostI Add the edge to the EST and check the conditionsI Update the WDJGI Repeat until
I no edges can reduce costs anymore orI no further nodes to consider
Step 2 - Find edges causing minimum increase to the result of joins
I Similar to Step 1I Start with the cheapest nodeI Find the incoming edge that increases the cost the least
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Example
Example
We start with a graph without virtual edgesTwo cost lists
I for the Step 1 Q1 = v14 v34 v12 v23
I for the Step 2 Q2 = empty
v12
500v23
50
v14
5000
v34
1000
5
05
05 5
50
10
01 2
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Example
v12
500v23
50
v14
5000
v14
5000
v14
3000
v34
1000
5
05
0505 5
50
10
01 2
Q1 = v14 v34 v12 v23 Q2 = emptyConsider v14 select the edge v12 rarr v14
After v12 is executed |R1 on R2| = 500Replace R1 by R1 on R2 in v14 = R1 on R4 v14 = (R1 on R2) on R4
cost(v14) = 500 lowast 100 lowast 005 + 500 = 3000
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Example
v12
500v23
50
v14
3000
v14
3000
v34
1000
5
05
05 5
50
10
01 2
v12
v23
v14
v34
Move v12 rarr v14 to ESTUpdate WDJG remove edges v14 rarr v12 and v12 rarr v23 add edge v14 rarr v23
Q1 = v14 v34 v12 v23 Q2 = emptyConsider v14 no more incoming edges with w lt 1Q1 = v34 v12 v23 Q2 = v14
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Example
v12
500v23
50
v14
3000
v34
1000
v34
1000
v34
150
v34
150
05
50
10
0101 2
v12 v23
v14 v34
Q1 = v34 v12 v23 Q2 = v14
Consider v34 select the edge v23 rarr v34
Recompute cost cost(v34) = 50 lowast 100 lowast 002 + 50 = 150Move to EST Update WDJGQ1 = v12 v34 v23 Q2 = v14
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Example
v12
500v12
500v23
50v23
50
v14
3000
v34
150
v34
150
v34
1000
50
10
v12 v23
v14 v34
Q1 = v12 v34 v23 Q2 = v14
Consider v12 no edgesv34 v23 no incoming edges with w lt 1Q1 = empty Q2 = v23 v34 v12 v14
End of Step 1
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Example
v12
500v23
50
v14
3000
v34
150
v34
1000
50
10
v12 v23
v14 v34
Q2 = v23 v34 v12 v14
Consider v23 edge v14 rarr v23
Adding the edge would not violate EST conditionsAdd edge to ESTDone
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming
Dynamic Programming
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming Overview
Overview
I generate optimal join trees bottom up
I start from optimal join trees of size one (relations)
I build larger join trees by (re-)using optimal solutions for smaller sizes
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming Overview
First Approach DPsizeLinear [2]
I Enumerate increasing in size
I Generate linear trees by adding a single relation at a time
ModificationsExtensions
I enumerate in integer order
I generate bushy trees by considering all pairs of subproblems
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming Example
Example
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming Example
R2
10
R1
10
R3
10
R4
10
01
05
0602
Query Optimization Exercise Session 6 November 27 2017
Homework
I Enumerate connected-subgraph-complement pairs
I Query Simplification
I Reordering constraints for non-inner joins
Query Optimization Exercise Session 6 November 27 2017
Lecture Evaluation
I Remember to bring your laptop for the lecture evaluation next week
Query Optimization Exercise Session 6 November 27 2017
Info
I Slides and exercises dbintumdeteachingws1718queryopt
I Send any questions comments solutions to exercises etc to radkeintumde
I Exercise due 9 AM December 4
Query Optimization Exercise Session 6 November 27 2017
References
[1] C Lee C Shih and Y ChenOptimizing large join queries using A graph-based approachIEEE Trans Knowl Data Eng 13(2)298ndash315 2001
[2] P G Selinger M M Astrahan D D Chamberlin R A Lorie and T G PriceAccess path selection in a relational database management systemIn Proceedings of the 1979 ACM SIGMOD International Conference on Management ofData Boston Massachusetts May 30 - June 1 pages 23ndash34 1979
Query Optimization Exercise Session 6 November 27 2017
- Maximum Value Precedence (MVP)
-
- Weighted Directed Join Graph (WDJG)
- Effective Spanning Tree (EST)
- MVP - informally
- Example
-
- Dynamic Programming
-
- Overview
- Example
-
- Homework
- Lecture Evaluation
- Info
- References
-
![Page 2: Query Optimization: Exercise · 2017. 11. 27. · I node costs: C out of the join v 12 500 23 50 v 14 5000 v 34 1000 5 0:5 0:5 50 10 1 2 Query Optimization: Exercise Session 6 November](https://reader036.fdocuments.us/reader036/viewer/2022071301/609dd6ee5426c42b823cc545/html5/thumbnails/2.jpg)
Maximum Value Precedence (MVP)
Maximum Value Precedence (MVP) [1]
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Weighted Directed Join Graph (WDJG)
Weighted Directed Join Graph (WDJG)
R1
1000
R2
100
R4
100
R3
500
0005
0001
002
005
Query graph to WDJG = (V EpEv )
I nodes V = joins
I physical edges Ep between rdquoadjacentrdquojoins (share one relation)
I virtual edges Ev everywhere else
I R(v) relations participating in join v
I Observation every spanning tree in theWDJG leads to a join tree
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Weighted Directed Join Graph (WDJG)
R1
1000
R2
100
R4
100
R3
500
0005
0001
002
005
v12
500
v23
50
v14
5000
v34
1000
5
05
05 5
50
10
01 2
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Weighted Directed Join Graph (WDJG)
Weights and Costs
I edge weights
wuv =
| u ||R(u)capR(v)| if (u v) isin Ep
1 if (u v) isin Ev
I node costs Cout of the join
v12
500v23
50
v14
5000
v34
1000
5
05
05 5
50
10
01 2
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Effective Spanning Tree (EST)
Effective Spanning Tree (EST)
Three conditions
1 EST is binary
2 For every non-leaf node vi for every edge vj rarr vi there is a common base relationbetween vi and the subtree with the root vj
3 For every node vi = R on S with two incoming edges vk rarr vi and vj rarr viI R or S can be present at most in one of the subtrees vk or vjI unless the subtree vj (or vk) contains both R and S
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) MVP - informally
MVP - informally
Construct an EST in two steps
Step 1 - Choose an edge to reduce the cost of an expensive operation
I Start with the most expensive nodeI Find the incoming edge that reduces the cost the mostI Add the edge to the EST and check the conditionsI Update the WDJGI Repeat until
I no edges can reduce costs anymore orI no further nodes to consider
Step 2 - Find edges causing minimum increase to the result of joins
I Similar to Step 1I Start with the cheapest nodeI Find the incoming edge that increases the cost the least
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Example
Example
We start with a graph without virtual edgesTwo cost lists
I for the Step 1 Q1 = v14 v34 v12 v23
I for the Step 2 Q2 = empty
v12
500v23
50
v14
5000
v34
1000
5
05
05 5
50
10
01 2
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Example
v12
500v23
50
v14
5000
v14
5000
v14
3000
v34
1000
5
05
0505 5
50
10
01 2
Q1 = v14 v34 v12 v23 Q2 = emptyConsider v14 select the edge v12 rarr v14
After v12 is executed |R1 on R2| = 500Replace R1 by R1 on R2 in v14 = R1 on R4 v14 = (R1 on R2) on R4
cost(v14) = 500 lowast 100 lowast 005 + 500 = 3000
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Example
v12
500v23
50
v14
3000
v14
3000
v34
1000
5
05
05 5
50
10
01 2
v12
v23
v14
v34
Move v12 rarr v14 to ESTUpdate WDJG remove edges v14 rarr v12 and v12 rarr v23 add edge v14 rarr v23
Q1 = v14 v34 v12 v23 Q2 = emptyConsider v14 no more incoming edges with w lt 1Q1 = v34 v12 v23 Q2 = v14
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Example
v12
500v23
50
v14
3000
v34
1000
v34
1000
v34
150
v34
150
05
50
10
0101 2
v12 v23
v14 v34
Q1 = v34 v12 v23 Q2 = v14
Consider v34 select the edge v23 rarr v34
Recompute cost cost(v34) = 50 lowast 100 lowast 002 + 50 = 150Move to EST Update WDJGQ1 = v12 v34 v23 Q2 = v14
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Example
v12
500v12
500v23
50v23
50
v14
3000
v34
150
v34
150
v34
1000
50
10
v12 v23
v14 v34
Q1 = v12 v34 v23 Q2 = v14
Consider v12 no edgesv34 v23 no incoming edges with w lt 1Q1 = empty Q2 = v23 v34 v12 v14
End of Step 1
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Example
v12
500v23
50
v14
3000
v34
150
v34
1000
50
10
v12 v23
v14 v34
Q2 = v23 v34 v12 v14
Consider v23 edge v14 rarr v23
Adding the edge would not violate EST conditionsAdd edge to ESTDone
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming
Dynamic Programming
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming Overview
Overview
I generate optimal join trees bottom up
I start from optimal join trees of size one (relations)
I build larger join trees by (re-)using optimal solutions for smaller sizes
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming Overview
First Approach DPsizeLinear [2]
I Enumerate increasing in size
I Generate linear trees by adding a single relation at a time
ModificationsExtensions
I enumerate in integer order
I generate bushy trees by considering all pairs of subproblems
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming Example
Example
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming Example
R2
10
R1
10
R3
10
R4
10
01
05
0602
Query Optimization Exercise Session 6 November 27 2017
Homework
I Enumerate connected-subgraph-complement pairs
I Query Simplification
I Reordering constraints for non-inner joins
Query Optimization Exercise Session 6 November 27 2017
Lecture Evaluation
I Remember to bring your laptop for the lecture evaluation next week
Query Optimization Exercise Session 6 November 27 2017
Info
I Slides and exercises dbintumdeteachingws1718queryopt
I Send any questions comments solutions to exercises etc to radkeintumde
I Exercise due 9 AM December 4
Query Optimization Exercise Session 6 November 27 2017
References
[1] C Lee C Shih and Y ChenOptimizing large join queries using A graph-based approachIEEE Trans Knowl Data Eng 13(2)298ndash315 2001
[2] P G Selinger M M Astrahan D D Chamberlin R A Lorie and T G PriceAccess path selection in a relational database management systemIn Proceedings of the 1979 ACM SIGMOD International Conference on Management ofData Boston Massachusetts May 30 - June 1 pages 23ndash34 1979
Query Optimization Exercise Session 6 November 27 2017
- Maximum Value Precedence (MVP)
-
- Weighted Directed Join Graph (WDJG)
- Effective Spanning Tree (EST)
- MVP - informally
- Example
-
- Dynamic Programming
-
- Overview
- Example
-
- Homework
- Lecture Evaluation
- Info
- References
-
![Page 3: Query Optimization: Exercise · 2017. 11. 27. · I node costs: C out of the join v 12 500 23 50 v 14 5000 v 34 1000 5 0:5 0:5 50 10 1 2 Query Optimization: Exercise Session 6 November](https://reader036.fdocuments.us/reader036/viewer/2022071301/609dd6ee5426c42b823cc545/html5/thumbnails/3.jpg)
Maximum Value Precedence (MVP) Weighted Directed Join Graph (WDJG)
Weighted Directed Join Graph (WDJG)
R1
1000
R2
100
R4
100
R3
500
0005
0001
002
005
Query graph to WDJG = (V EpEv )
I nodes V = joins
I physical edges Ep between rdquoadjacentrdquojoins (share one relation)
I virtual edges Ev everywhere else
I R(v) relations participating in join v
I Observation every spanning tree in theWDJG leads to a join tree
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Weighted Directed Join Graph (WDJG)
R1
1000
R2
100
R4
100
R3
500
0005
0001
002
005
v12
500
v23
50
v14
5000
v34
1000
5
05
05 5
50
10
01 2
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Weighted Directed Join Graph (WDJG)
Weights and Costs
I edge weights
wuv =
| u ||R(u)capR(v)| if (u v) isin Ep
1 if (u v) isin Ev
I node costs Cout of the join
v12
500v23
50
v14
5000
v34
1000
5
05
05 5
50
10
01 2
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Effective Spanning Tree (EST)
Effective Spanning Tree (EST)
Three conditions
1 EST is binary
2 For every non-leaf node vi for every edge vj rarr vi there is a common base relationbetween vi and the subtree with the root vj
3 For every node vi = R on S with two incoming edges vk rarr vi and vj rarr viI R or S can be present at most in one of the subtrees vk or vjI unless the subtree vj (or vk) contains both R and S
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) MVP - informally
MVP - informally
Construct an EST in two steps
Step 1 - Choose an edge to reduce the cost of an expensive operation
I Start with the most expensive nodeI Find the incoming edge that reduces the cost the mostI Add the edge to the EST and check the conditionsI Update the WDJGI Repeat until
I no edges can reduce costs anymore orI no further nodes to consider
Step 2 - Find edges causing minimum increase to the result of joins
I Similar to Step 1I Start with the cheapest nodeI Find the incoming edge that increases the cost the least
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Example
Example
We start with a graph without virtual edgesTwo cost lists
I for the Step 1 Q1 = v14 v34 v12 v23
I for the Step 2 Q2 = empty
v12
500v23
50
v14
5000
v34
1000
5
05
05 5
50
10
01 2
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Example
v12
500v23
50
v14
5000
v14
5000
v14
3000
v34
1000
5
05
0505 5
50
10
01 2
Q1 = v14 v34 v12 v23 Q2 = emptyConsider v14 select the edge v12 rarr v14
After v12 is executed |R1 on R2| = 500Replace R1 by R1 on R2 in v14 = R1 on R4 v14 = (R1 on R2) on R4
cost(v14) = 500 lowast 100 lowast 005 + 500 = 3000
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Example
v12
500v23
50
v14
3000
v14
3000
v34
1000
5
05
05 5
50
10
01 2
v12
v23
v14
v34
Move v12 rarr v14 to ESTUpdate WDJG remove edges v14 rarr v12 and v12 rarr v23 add edge v14 rarr v23
Q1 = v14 v34 v12 v23 Q2 = emptyConsider v14 no more incoming edges with w lt 1Q1 = v34 v12 v23 Q2 = v14
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Example
v12
500v23
50
v14
3000
v34
1000
v34
1000
v34
150
v34
150
05
50
10
0101 2
v12 v23
v14 v34
Q1 = v34 v12 v23 Q2 = v14
Consider v34 select the edge v23 rarr v34
Recompute cost cost(v34) = 50 lowast 100 lowast 002 + 50 = 150Move to EST Update WDJGQ1 = v12 v34 v23 Q2 = v14
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Example
v12
500v12
500v23
50v23
50
v14
3000
v34
150
v34
150
v34
1000
50
10
v12 v23
v14 v34
Q1 = v12 v34 v23 Q2 = v14
Consider v12 no edgesv34 v23 no incoming edges with w lt 1Q1 = empty Q2 = v23 v34 v12 v14
End of Step 1
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Example
v12
500v23
50
v14
3000
v34
150
v34
1000
50
10
v12 v23
v14 v34
Q2 = v23 v34 v12 v14
Consider v23 edge v14 rarr v23
Adding the edge would not violate EST conditionsAdd edge to ESTDone
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming
Dynamic Programming
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming Overview
Overview
I generate optimal join trees bottom up
I start from optimal join trees of size one (relations)
I build larger join trees by (re-)using optimal solutions for smaller sizes
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming Overview
First Approach DPsizeLinear [2]
I Enumerate increasing in size
I Generate linear trees by adding a single relation at a time
ModificationsExtensions
I enumerate in integer order
I generate bushy trees by considering all pairs of subproblems
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming Example
Example
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming Example
R2
10
R1
10
R3
10
R4
10
01
05
0602
Query Optimization Exercise Session 6 November 27 2017
Homework
I Enumerate connected-subgraph-complement pairs
I Query Simplification
I Reordering constraints for non-inner joins
Query Optimization Exercise Session 6 November 27 2017
Lecture Evaluation
I Remember to bring your laptop for the lecture evaluation next week
Query Optimization Exercise Session 6 November 27 2017
Info
I Slides and exercises dbintumdeteachingws1718queryopt
I Send any questions comments solutions to exercises etc to radkeintumde
I Exercise due 9 AM December 4
Query Optimization Exercise Session 6 November 27 2017
References
[1] C Lee C Shih and Y ChenOptimizing large join queries using A graph-based approachIEEE Trans Knowl Data Eng 13(2)298ndash315 2001
[2] P G Selinger M M Astrahan D D Chamberlin R A Lorie and T G PriceAccess path selection in a relational database management systemIn Proceedings of the 1979 ACM SIGMOD International Conference on Management ofData Boston Massachusetts May 30 - June 1 pages 23ndash34 1979
Query Optimization Exercise Session 6 November 27 2017
- Maximum Value Precedence (MVP)
-
- Weighted Directed Join Graph (WDJG)
- Effective Spanning Tree (EST)
- MVP - informally
- Example
-
- Dynamic Programming
-
- Overview
- Example
-
- Homework
- Lecture Evaluation
- Info
- References
-
![Page 4: Query Optimization: Exercise · 2017. 11. 27. · I node costs: C out of the join v 12 500 23 50 v 14 5000 v 34 1000 5 0:5 0:5 50 10 1 2 Query Optimization: Exercise Session 6 November](https://reader036.fdocuments.us/reader036/viewer/2022071301/609dd6ee5426c42b823cc545/html5/thumbnails/4.jpg)
Maximum Value Precedence (MVP) Weighted Directed Join Graph (WDJG)
R1
1000
R2
100
R4
100
R3
500
0005
0001
002
005
v12
500
v23
50
v14
5000
v34
1000
5
05
05 5
50
10
01 2
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Weighted Directed Join Graph (WDJG)
Weights and Costs
I edge weights
wuv =
| u ||R(u)capR(v)| if (u v) isin Ep
1 if (u v) isin Ev
I node costs Cout of the join
v12
500v23
50
v14
5000
v34
1000
5
05
05 5
50
10
01 2
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Effective Spanning Tree (EST)
Effective Spanning Tree (EST)
Three conditions
1 EST is binary
2 For every non-leaf node vi for every edge vj rarr vi there is a common base relationbetween vi and the subtree with the root vj
3 For every node vi = R on S with two incoming edges vk rarr vi and vj rarr viI R or S can be present at most in one of the subtrees vk or vjI unless the subtree vj (or vk) contains both R and S
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) MVP - informally
MVP - informally
Construct an EST in two steps
Step 1 - Choose an edge to reduce the cost of an expensive operation
I Start with the most expensive nodeI Find the incoming edge that reduces the cost the mostI Add the edge to the EST and check the conditionsI Update the WDJGI Repeat until
I no edges can reduce costs anymore orI no further nodes to consider
Step 2 - Find edges causing minimum increase to the result of joins
I Similar to Step 1I Start with the cheapest nodeI Find the incoming edge that increases the cost the least
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Example
Example
We start with a graph without virtual edgesTwo cost lists
I for the Step 1 Q1 = v14 v34 v12 v23
I for the Step 2 Q2 = empty
v12
500v23
50
v14
5000
v34
1000
5
05
05 5
50
10
01 2
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Example
v12
500v23
50
v14
5000
v14
5000
v14
3000
v34
1000
5
05
0505 5
50
10
01 2
Q1 = v14 v34 v12 v23 Q2 = emptyConsider v14 select the edge v12 rarr v14
After v12 is executed |R1 on R2| = 500Replace R1 by R1 on R2 in v14 = R1 on R4 v14 = (R1 on R2) on R4
cost(v14) = 500 lowast 100 lowast 005 + 500 = 3000
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Example
v12
500v23
50
v14
3000
v14
3000
v34
1000
5
05
05 5
50
10
01 2
v12
v23
v14
v34
Move v12 rarr v14 to ESTUpdate WDJG remove edges v14 rarr v12 and v12 rarr v23 add edge v14 rarr v23
Q1 = v14 v34 v12 v23 Q2 = emptyConsider v14 no more incoming edges with w lt 1Q1 = v34 v12 v23 Q2 = v14
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Example
v12
500v23
50
v14
3000
v34
1000
v34
1000
v34
150
v34
150
05
50
10
0101 2
v12 v23
v14 v34
Q1 = v34 v12 v23 Q2 = v14
Consider v34 select the edge v23 rarr v34
Recompute cost cost(v34) = 50 lowast 100 lowast 002 + 50 = 150Move to EST Update WDJGQ1 = v12 v34 v23 Q2 = v14
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Example
v12
500v12
500v23
50v23
50
v14
3000
v34
150
v34
150
v34
1000
50
10
v12 v23
v14 v34
Q1 = v12 v34 v23 Q2 = v14
Consider v12 no edgesv34 v23 no incoming edges with w lt 1Q1 = empty Q2 = v23 v34 v12 v14
End of Step 1
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Example
v12
500v23
50
v14
3000
v34
150
v34
1000
50
10
v12 v23
v14 v34
Q2 = v23 v34 v12 v14
Consider v23 edge v14 rarr v23
Adding the edge would not violate EST conditionsAdd edge to ESTDone
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming
Dynamic Programming
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming Overview
Overview
I generate optimal join trees bottom up
I start from optimal join trees of size one (relations)
I build larger join trees by (re-)using optimal solutions for smaller sizes
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming Overview
First Approach DPsizeLinear [2]
I Enumerate increasing in size
I Generate linear trees by adding a single relation at a time
ModificationsExtensions
I enumerate in integer order
I generate bushy trees by considering all pairs of subproblems
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming Example
Example
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming Example
R2
10
R1
10
R3
10
R4
10
01
05
0602
Query Optimization Exercise Session 6 November 27 2017
Homework
I Enumerate connected-subgraph-complement pairs
I Query Simplification
I Reordering constraints for non-inner joins
Query Optimization Exercise Session 6 November 27 2017
Lecture Evaluation
I Remember to bring your laptop for the lecture evaluation next week
Query Optimization Exercise Session 6 November 27 2017
Info
I Slides and exercises dbintumdeteachingws1718queryopt
I Send any questions comments solutions to exercises etc to radkeintumde
I Exercise due 9 AM December 4
Query Optimization Exercise Session 6 November 27 2017
References
[1] C Lee C Shih and Y ChenOptimizing large join queries using A graph-based approachIEEE Trans Knowl Data Eng 13(2)298ndash315 2001
[2] P G Selinger M M Astrahan D D Chamberlin R A Lorie and T G PriceAccess path selection in a relational database management systemIn Proceedings of the 1979 ACM SIGMOD International Conference on Management ofData Boston Massachusetts May 30 - June 1 pages 23ndash34 1979
Query Optimization Exercise Session 6 November 27 2017
- Maximum Value Precedence (MVP)
-
- Weighted Directed Join Graph (WDJG)
- Effective Spanning Tree (EST)
- MVP - informally
- Example
-
- Dynamic Programming
-
- Overview
- Example
-
- Homework
- Lecture Evaluation
- Info
- References
-
![Page 5: Query Optimization: Exercise · 2017. 11. 27. · I node costs: C out of the join v 12 500 23 50 v 14 5000 v 34 1000 5 0:5 0:5 50 10 1 2 Query Optimization: Exercise Session 6 November](https://reader036.fdocuments.us/reader036/viewer/2022071301/609dd6ee5426c42b823cc545/html5/thumbnails/5.jpg)
Maximum Value Precedence (MVP) Weighted Directed Join Graph (WDJG)
Weights and Costs
I edge weights
wuv =
| u ||R(u)capR(v)| if (u v) isin Ep
1 if (u v) isin Ev
I node costs Cout of the join
v12
500v23
50
v14
5000
v34
1000
5
05
05 5
50
10
01 2
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Effective Spanning Tree (EST)
Effective Spanning Tree (EST)
Three conditions
1 EST is binary
2 For every non-leaf node vi for every edge vj rarr vi there is a common base relationbetween vi and the subtree with the root vj
3 For every node vi = R on S with two incoming edges vk rarr vi and vj rarr viI R or S can be present at most in one of the subtrees vk or vjI unless the subtree vj (or vk) contains both R and S
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) MVP - informally
MVP - informally
Construct an EST in two steps
Step 1 - Choose an edge to reduce the cost of an expensive operation
I Start with the most expensive nodeI Find the incoming edge that reduces the cost the mostI Add the edge to the EST and check the conditionsI Update the WDJGI Repeat until
I no edges can reduce costs anymore orI no further nodes to consider
Step 2 - Find edges causing minimum increase to the result of joins
I Similar to Step 1I Start with the cheapest nodeI Find the incoming edge that increases the cost the least
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Example
Example
We start with a graph without virtual edgesTwo cost lists
I for the Step 1 Q1 = v14 v34 v12 v23
I for the Step 2 Q2 = empty
v12
500v23
50
v14
5000
v34
1000
5
05
05 5
50
10
01 2
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Example
v12
500v23
50
v14
5000
v14
5000
v14
3000
v34
1000
5
05
0505 5
50
10
01 2
Q1 = v14 v34 v12 v23 Q2 = emptyConsider v14 select the edge v12 rarr v14
After v12 is executed |R1 on R2| = 500Replace R1 by R1 on R2 in v14 = R1 on R4 v14 = (R1 on R2) on R4
cost(v14) = 500 lowast 100 lowast 005 + 500 = 3000
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Example
v12
500v23
50
v14
3000
v14
3000
v34
1000
5
05
05 5
50
10
01 2
v12
v23
v14
v34
Move v12 rarr v14 to ESTUpdate WDJG remove edges v14 rarr v12 and v12 rarr v23 add edge v14 rarr v23
Q1 = v14 v34 v12 v23 Q2 = emptyConsider v14 no more incoming edges with w lt 1Q1 = v34 v12 v23 Q2 = v14
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Example
v12
500v23
50
v14
3000
v34
1000
v34
1000
v34
150
v34
150
05
50
10
0101 2
v12 v23
v14 v34
Q1 = v34 v12 v23 Q2 = v14
Consider v34 select the edge v23 rarr v34
Recompute cost cost(v34) = 50 lowast 100 lowast 002 + 50 = 150Move to EST Update WDJGQ1 = v12 v34 v23 Q2 = v14
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Example
v12
500v12
500v23
50v23
50
v14
3000
v34
150
v34
150
v34
1000
50
10
v12 v23
v14 v34
Q1 = v12 v34 v23 Q2 = v14
Consider v12 no edgesv34 v23 no incoming edges with w lt 1Q1 = empty Q2 = v23 v34 v12 v14
End of Step 1
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Example
v12
500v23
50
v14
3000
v34
150
v34
1000
50
10
v12 v23
v14 v34
Q2 = v23 v34 v12 v14
Consider v23 edge v14 rarr v23
Adding the edge would not violate EST conditionsAdd edge to ESTDone
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming
Dynamic Programming
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming Overview
Overview
I generate optimal join trees bottom up
I start from optimal join trees of size one (relations)
I build larger join trees by (re-)using optimal solutions for smaller sizes
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming Overview
First Approach DPsizeLinear [2]
I Enumerate increasing in size
I Generate linear trees by adding a single relation at a time
ModificationsExtensions
I enumerate in integer order
I generate bushy trees by considering all pairs of subproblems
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming Example
Example
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming Example
R2
10
R1
10
R3
10
R4
10
01
05
0602
Query Optimization Exercise Session 6 November 27 2017
Homework
I Enumerate connected-subgraph-complement pairs
I Query Simplification
I Reordering constraints for non-inner joins
Query Optimization Exercise Session 6 November 27 2017
Lecture Evaluation
I Remember to bring your laptop for the lecture evaluation next week
Query Optimization Exercise Session 6 November 27 2017
Info
I Slides and exercises dbintumdeteachingws1718queryopt
I Send any questions comments solutions to exercises etc to radkeintumde
I Exercise due 9 AM December 4
Query Optimization Exercise Session 6 November 27 2017
References
[1] C Lee C Shih and Y ChenOptimizing large join queries using A graph-based approachIEEE Trans Knowl Data Eng 13(2)298ndash315 2001
[2] P G Selinger M M Astrahan D D Chamberlin R A Lorie and T G PriceAccess path selection in a relational database management systemIn Proceedings of the 1979 ACM SIGMOD International Conference on Management ofData Boston Massachusetts May 30 - June 1 pages 23ndash34 1979
Query Optimization Exercise Session 6 November 27 2017
- Maximum Value Precedence (MVP)
-
- Weighted Directed Join Graph (WDJG)
- Effective Spanning Tree (EST)
- MVP - informally
- Example
-
- Dynamic Programming
-
- Overview
- Example
-
- Homework
- Lecture Evaluation
- Info
- References
-
![Page 6: Query Optimization: Exercise · 2017. 11. 27. · I node costs: C out of the join v 12 500 23 50 v 14 5000 v 34 1000 5 0:5 0:5 50 10 1 2 Query Optimization: Exercise Session 6 November](https://reader036.fdocuments.us/reader036/viewer/2022071301/609dd6ee5426c42b823cc545/html5/thumbnails/6.jpg)
Maximum Value Precedence (MVP) Effective Spanning Tree (EST)
Effective Spanning Tree (EST)
Three conditions
1 EST is binary
2 For every non-leaf node vi for every edge vj rarr vi there is a common base relationbetween vi and the subtree with the root vj
3 For every node vi = R on S with two incoming edges vk rarr vi and vj rarr viI R or S can be present at most in one of the subtrees vk or vjI unless the subtree vj (or vk) contains both R and S
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) MVP - informally
MVP - informally
Construct an EST in two steps
Step 1 - Choose an edge to reduce the cost of an expensive operation
I Start with the most expensive nodeI Find the incoming edge that reduces the cost the mostI Add the edge to the EST and check the conditionsI Update the WDJGI Repeat until
I no edges can reduce costs anymore orI no further nodes to consider
Step 2 - Find edges causing minimum increase to the result of joins
I Similar to Step 1I Start with the cheapest nodeI Find the incoming edge that increases the cost the least
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Example
Example
We start with a graph without virtual edgesTwo cost lists
I for the Step 1 Q1 = v14 v34 v12 v23
I for the Step 2 Q2 = empty
v12
500v23
50
v14
5000
v34
1000
5
05
05 5
50
10
01 2
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Example
v12
500v23
50
v14
5000
v14
5000
v14
3000
v34
1000
5
05
0505 5
50
10
01 2
Q1 = v14 v34 v12 v23 Q2 = emptyConsider v14 select the edge v12 rarr v14
After v12 is executed |R1 on R2| = 500Replace R1 by R1 on R2 in v14 = R1 on R4 v14 = (R1 on R2) on R4
cost(v14) = 500 lowast 100 lowast 005 + 500 = 3000
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Example
v12
500v23
50
v14
3000
v14
3000
v34
1000
5
05
05 5
50
10
01 2
v12
v23
v14
v34
Move v12 rarr v14 to ESTUpdate WDJG remove edges v14 rarr v12 and v12 rarr v23 add edge v14 rarr v23
Q1 = v14 v34 v12 v23 Q2 = emptyConsider v14 no more incoming edges with w lt 1Q1 = v34 v12 v23 Q2 = v14
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Example
v12
500v23
50
v14
3000
v34
1000
v34
1000
v34
150
v34
150
05
50
10
0101 2
v12 v23
v14 v34
Q1 = v34 v12 v23 Q2 = v14
Consider v34 select the edge v23 rarr v34
Recompute cost cost(v34) = 50 lowast 100 lowast 002 + 50 = 150Move to EST Update WDJGQ1 = v12 v34 v23 Q2 = v14
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Example
v12
500v12
500v23
50v23
50
v14
3000
v34
150
v34
150
v34
1000
50
10
v12 v23
v14 v34
Q1 = v12 v34 v23 Q2 = v14
Consider v12 no edgesv34 v23 no incoming edges with w lt 1Q1 = empty Q2 = v23 v34 v12 v14
End of Step 1
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Example
v12
500v23
50
v14
3000
v34
150
v34
1000
50
10
v12 v23
v14 v34
Q2 = v23 v34 v12 v14
Consider v23 edge v14 rarr v23
Adding the edge would not violate EST conditionsAdd edge to ESTDone
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming
Dynamic Programming
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming Overview
Overview
I generate optimal join trees bottom up
I start from optimal join trees of size one (relations)
I build larger join trees by (re-)using optimal solutions for smaller sizes
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming Overview
First Approach DPsizeLinear [2]
I Enumerate increasing in size
I Generate linear trees by adding a single relation at a time
ModificationsExtensions
I enumerate in integer order
I generate bushy trees by considering all pairs of subproblems
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming Example
Example
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming Example
R2
10
R1
10
R3
10
R4
10
01
05
0602
Query Optimization Exercise Session 6 November 27 2017
Homework
I Enumerate connected-subgraph-complement pairs
I Query Simplification
I Reordering constraints for non-inner joins
Query Optimization Exercise Session 6 November 27 2017
Lecture Evaluation
I Remember to bring your laptop for the lecture evaluation next week
Query Optimization Exercise Session 6 November 27 2017
Info
I Slides and exercises dbintumdeteachingws1718queryopt
I Send any questions comments solutions to exercises etc to radkeintumde
I Exercise due 9 AM December 4
Query Optimization Exercise Session 6 November 27 2017
References
[1] C Lee C Shih and Y ChenOptimizing large join queries using A graph-based approachIEEE Trans Knowl Data Eng 13(2)298ndash315 2001
[2] P G Selinger M M Astrahan D D Chamberlin R A Lorie and T G PriceAccess path selection in a relational database management systemIn Proceedings of the 1979 ACM SIGMOD International Conference on Management ofData Boston Massachusetts May 30 - June 1 pages 23ndash34 1979
Query Optimization Exercise Session 6 November 27 2017
- Maximum Value Precedence (MVP)
-
- Weighted Directed Join Graph (WDJG)
- Effective Spanning Tree (EST)
- MVP - informally
- Example
-
- Dynamic Programming
-
- Overview
- Example
-
- Homework
- Lecture Evaluation
- Info
- References
-
![Page 7: Query Optimization: Exercise · 2017. 11. 27. · I node costs: C out of the join v 12 500 23 50 v 14 5000 v 34 1000 5 0:5 0:5 50 10 1 2 Query Optimization: Exercise Session 6 November](https://reader036.fdocuments.us/reader036/viewer/2022071301/609dd6ee5426c42b823cc545/html5/thumbnails/7.jpg)
Maximum Value Precedence (MVP) MVP - informally
MVP - informally
Construct an EST in two steps
Step 1 - Choose an edge to reduce the cost of an expensive operation
I Start with the most expensive nodeI Find the incoming edge that reduces the cost the mostI Add the edge to the EST and check the conditionsI Update the WDJGI Repeat until
I no edges can reduce costs anymore orI no further nodes to consider
Step 2 - Find edges causing minimum increase to the result of joins
I Similar to Step 1I Start with the cheapest nodeI Find the incoming edge that increases the cost the least
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Example
Example
We start with a graph without virtual edgesTwo cost lists
I for the Step 1 Q1 = v14 v34 v12 v23
I for the Step 2 Q2 = empty
v12
500v23
50
v14
5000
v34
1000
5
05
05 5
50
10
01 2
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Example
v12
500v23
50
v14
5000
v14
5000
v14
3000
v34
1000
5
05
0505 5
50
10
01 2
Q1 = v14 v34 v12 v23 Q2 = emptyConsider v14 select the edge v12 rarr v14
After v12 is executed |R1 on R2| = 500Replace R1 by R1 on R2 in v14 = R1 on R4 v14 = (R1 on R2) on R4
cost(v14) = 500 lowast 100 lowast 005 + 500 = 3000
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Example
v12
500v23
50
v14
3000
v14
3000
v34
1000
5
05
05 5
50
10
01 2
v12
v23
v14
v34
Move v12 rarr v14 to ESTUpdate WDJG remove edges v14 rarr v12 and v12 rarr v23 add edge v14 rarr v23
Q1 = v14 v34 v12 v23 Q2 = emptyConsider v14 no more incoming edges with w lt 1Q1 = v34 v12 v23 Q2 = v14
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Example
v12
500v23
50
v14
3000
v34
1000
v34
1000
v34
150
v34
150
05
50
10
0101 2
v12 v23
v14 v34
Q1 = v34 v12 v23 Q2 = v14
Consider v34 select the edge v23 rarr v34
Recompute cost cost(v34) = 50 lowast 100 lowast 002 + 50 = 150Move to EST Update WDJGQ1 = v12 v34 v23 Q2 = v14
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Example
v12
500v12
500v23
50v23
50
v14
3000
v34
150
v34
150
v34
1000
50
10
v12 v23
v14 v34
Q1 = v12 v34 v23 Q2 = v14
Consider v12 no edgesv34 v23 no incoming edges with w lt 1Q1 = empty Q2 = v23 v34 v12 v14
End of Step 1
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Example
v12
500v23
50
v14
3000
v34
150
v34
1000
50
10
v12 v23
v14 v34
Q2 = v23 v34 v12 v14
Consider v23 edge v14 rarr v23
Adding the edge would not violate EST conditionsAdd edge to ESTDone
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming
Dynamic Programming
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming Overview
Overview
I generate optimal join trees bottom up
I start from optimal join trees of size one (relations)
I build larger join trees by (re-)using optimal solutions for smaller sizes
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming Overview
First Approach DPsizeLinear [2]
I Enumerate increasing in size
I Generate linear trees by adding a single relation at a time
ModificationsExtensions
I enumerate in integer order
I generate bushy trees by considering all pairs of subproblems
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming Example
Example
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming Example
R2
10
R1
10
R3
10
R4
10
01
05
0602
Query Optimization Exercise Session 6 November 27 2017
Homework
I Enumerate connected-subgraph-complement pairs
I Query Simplification
I Reordering constraints for non-inner joins
Query Optimization Exercise Session 6 November 27 2017
Lecture Evaluation
I Remember to bring your laptop for the lecture evaluation next week
Query Optimization Exercise Session 6 November 27 2017
Info
I Slides and exercises dbintumdeteachingws1718queryopt
I Send any questions comments solutions to exercises etc to radkeintumde
I Exercise due 9 AM December 4
Query Optimization Exercise Session 6 November 27 2017
References
[1] C Lee C Shih and Y ChenOptimizing large join queries using A graph-based approachIEEE Trans Knowl Data Eng 13(2)298ndash315 2001
[2] P G Selinger M M Astrahan D D Chamberlin R A Lorie and T G PriceAccess path selection in a relational database management systemIn Proceedings of the 1979 ACM SIGMOD International Conference on Management ofData Boston Massachusetts May 30 - June 1 pages 23ndash34 1979
Query Optimization Exercise Session 6 November 27 2017
- Maximum Value Precedence (MVP)
-
- Weighted Directed Join Graph (WDJG)
- Effective Spanning Tree (EST)
- MVP - informally
- Example
-
- Dynamic Programming
-
- Overview
- Example
-
- Homework
- Lecture Evaluation
- Info
- References
-
![Page 8: Query Optimization: Exercise · 2017. 11. 27. · I node costs: C out of the join v 12 500 23 50 v 14 5000 v 34 1000 5 0:5 0:5 50 10 1 2 Query Optimization: Exercise Session 6 November](https://reader036.fdocuments.us/reader036/viewer/2022071301/609dd6ee5426c42b823cc545/html5/thumbnails/8.jpg)
Maximum Value Precedence (MVP) Example
Example
We start with a graph without virtual edgesTwo cost lists
I for the Step 1 Q1 = v14 v34 v12 v23
I for the Step 2 Q2 = empty
v12
500v23
50
v14
5000
v34
1000
5
05
05 5
50
10
01 2
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Example
v12
500v23
50
v14
5000
v14
5000
v14
3000
v34
1000
5
05
0505 5
50
10
01 2
Q1 = v14 v34 v12 v23 Q2 = emptyConsider v14 select the edge v12 rarr v14
After v12 is executed |R1 on R2| = 500Replace R1 by R1 on R2 in v14 = R1 on R4 v14 = (R1 on R2) on R4
cost(v14) = 500 lowast 100 lowast 005 + 500 = 3000
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Example
v12
500v23
50
v14
3000
v14
3000
v34
1000
5
05
05 5
50
10
01 2
v12
v23
v14
v34
Move v12 rarr v14 to ESTUpdate WDJG remove edges v14 rarr v12 and v12 rarr v23 add edge v14 rarr v23
Q1 = v14 v34 v12 v23 Q2 = emptyConsider v14 no more incoming edges with w lt 1Q1 = v34 v12 v23 Q2 = v14
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Example
v12
500v23
50
v14
3000
v34
1000
v34
1000
v34
150
v34
150
05
50
10
0101 2
v12 v23
v14 v34
Q1 = v34 v12 v23 Q2 = v14
Consider v34 select the edge v23 rarr v34
Recompute cost cost(v34) = 50 lowast 100 lowast 002 + 50 = 150Move to EST Update WDJGQ1 = v12 v34 v23 Q2 = v14
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Example
v12
500v12
500v23
50v23
50
v14
3000
v34
150
v34
150
v34
1000
50
10
v12 v23
v14 v34
Q1 = v12 v34 v23 Q2 = v14
Consider v12 no edgesv34 v23 no incoming edges with w lt 1Q1 = empty Q2 = v23 v34 v12 v14
End of Step 1
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Example
v12
500v23
50
v14
3000
v34
150
v34
1000
50
10
v12 v23
v14 v34
Q2 = v23 v34 v12 v14
Consider v23 edge v14 rarr v23
Adding the edge would not violate EST conditionsAdd edge to ESTDone
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming
Dynamic Programming
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming Overview
Overview
I generate optimal join trees bottom up
I start from optimal join trees of size one (relations)
I build larger join trees by (re-)using optimal solutions for smaller sizes
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming Overview
First Approach DPsizeLinear [2]
I Enumerate increasing in size
I Generate linear trees by adding a single relation at a time
ModificationsExtensions
I enumerate in integer order
I generate bushy trees by considering all pairs of subproblems
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming Example
Example
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming Example
R2
10
R1
10
R3
10
R4
10
01
05
0602
Query Optimization Exercise Session 6 November 27 2017
Homework
I Enumerate connected-subgraph-complement pairs
I Query Simplification
I Reordering constraints for non-inner joins
Query Optimization Exercise Session 6 November 27 2017
Lecture Evaluation
I Remember to bring your laptop for the lecture evaluation next week
Query Optimization Exercise Session 6 November 27 2017
Info
I Slides and exercises dbintumdeteachingws1718queryopt
I Send any questions comments solutions to exercises etc to radkeintumde
I Exercise due 9 AM December 4
Query Optimization Exercise Session 6 November 27 2017
References
[1] C Lee C Shih and Y ChenOptimizing large join queries using A graph-based approachIEEE Trans Knowl Data Eng 13(2)298ndash315 2001
[2] P G Selinger M M Astrahan D D Chamberlin R A Lorie and T G PriceAccess path selection in a relational database management systemIn Proceedings of the 1979 ACM SIGMOD International Conference on Management ofData Boston Massachusetts May 30 - June 1 pages 23ndash34 1979
Query Optimization Exercise Session 6 November 27 2017
- Maximum Value Precedence (MVP)
-
- Weighted Directed Join Graph (WDJG)
- Effective Spanning Tree (EST)
- MVP - informally
- Example
-
- Dynamic Programming
-
- Overview
- Example
-
- Homework
- Lecture Evaluation
- Info
- References
-
![Page 9: Query Optimization: Exercise · 2017. 11. 27. · I node costs: C out of the join v 12 500 23 50 v 14 5000 v 34 1000 5 0:5 0:5 50 10 1 2 Query Optimization: Exercise Session 6 November](https://reader036.fdocuments.us/reader036/viewer/2022071301/609dd6ee5426c42b823cc545/html5/thumbnails/9.jpg)
Maximum Value Precedence (MVP) Example
v12
500v23
50
v14
5000
v14
5000
v14
3000
v34
1000
5
05
0505 5
50
10
01 2
Q1 = v14 v34 v12 v23 Q2 = emptyConsider v14 select the edge v12 rarr v14
After v12 is executed |R1 on R2| = 500Replace R1 by R1 on R2 in v14 = R1 on R4 v14 = (R1 on R2) on R4
cost(v14) = 500 lowast 100 lowast 005 + 500 = 3000
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Example
v12
500v23
50
v14
3000
v14
3000
v34
1000
5
05
05 5
50
10
01 2
v12
v23
v14
v34
Move v12 rarr v14 to ESTUpdate WDJG remove edges v14 rarr v12 and v12 rarr v23 add edge v14 rarr v23
Q1 = v14 v34 v12 v23 Q2 = emptyConsider v14 no more incoming edges with w lt 1Q1 = v34 v12 v23 Q2 = v14
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Example
v12
500v23
50
v14
3000
v34
1000
v34
1000
v34
150
v34
150
05
50
10
0101 2
v12 v23
v14 v34
Q1 = v34 v12 v23 Q2 = v14
Consider v34 select the edge v23 rarr v34
Recompute cost cost(v34) = 50 lowast 100 lowast 002 + 50 = 150Move to EST Update WDJGQ1 = v12 v34 v23 Q2 = v14
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Example
v12
500v12
500v23
50v23
50
v14
3000
v34
150
v34
150
v34
1000
50
10
v12 v23
v14 v34
Q1 = v12 v34 v23 Q2 = v14
Consider v12 no edgesv34 v23 no incoming edges with w lt 1Q1 = empty Q2 = v23 v34 v12 v14
End of Step 1
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Example
v12
500v23
50
v14
3000
v34
150
v34
1000
50
10
v12 v23
v14 v34
Q2 = v23 v34 v12 v14
Consider v23 edge v14 rarr v23
Adding the edge would not violate EST conditionsAdd edge to ESTDone
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming
Dynamic Programming
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming Overview
Overview
I generate optimal join trees bottom up
I start from optimal join trees of size one (relations)
I build larger join trees by (re-)using optimal solutions for smaller sizes
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming Overview
First Approach DPsizeLinear [2]
I Enumerate increasing in size
I Generate linear trees by adding a single relation at a time
ModificationsExtensions
I enumerate in integer order
I generate bushy trees by considering all pairs of subproblems
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming Example
Example
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming Example
R2
10
R1
10
R3
10
R4
10
01
05
0602
Query Optimization Exercise Session 6 November 27 2017
Homework
I Enumerate connected-subgraph-complement pairs
I Query Simplification
I Reordering constraints for non-inner joins
Query Optimization Exercise Session 6 November 27 2017
Lecture Evaluation
I Remember to bring your laptop for the lecture evaluation next week
Query Optimization Exercise Session 6 November 27 2017
Info
I Slides and exercises dbintumdeteachingws1718queryopt
I Send any questions comments solutions to exercises etc to radkeintumde
I Exercise due 9 AM December 4
Query Optimization Exercise Session 6 November 27 2017
References
[1] C Lee C Shih and Y ChenOptimizing large join queries using A graph-based approachIEEE Trans Knowl Data Eng 13(2)298ndash315 2001
[2] P G Selinger M M Astrahan D D Chamberlin R A Lorie and T G PriceAccess path selection in a relational database management systemIn Proceedings of the 1979 ACM SIGMOD International Conference on Management ofData Boston Massachusetts May 30 - June 1 pages 23ndash34 1979
Query Optimization Exercise Session 6 November 27 2017
- Maximum Value Precedence (MVP)
-
- Weighted Directed Join Graph (WDJG)
- Effective Spanning Tree (EST)
- MVP - informally
- Example
-
- Dynamic Programming
-
- Overview
- Example
-
- Homework
- Lecture Evaluation
- Info
- References
-
![Page 10: Query Optimization: Exercise · 2017. 11. 27. · I node costs: C out of the join v 12 500 23 50 v 14 5000 v 34 1000 5 0:5 0:5 50 10 1 2 Query Optimization: Exercise Session 6 November](https://reader036.fdocuments.us/reader036/viewer/2022071301/609dd6ee5426c42b823cc545/html5/thumbnails/10.jpg)
Maximum Value Precedence (MVP) Example
v12
500v23
50
v14
3000
v14
3000
v34
1000
5
05
05 5
50
10
01 2
v12
v23
v14
v34
Move v12 rarr v14 to ESTUpdate WDJG remove edges v14 rarr v12 and v12 rarr v23 add edge v14 rarr v23
Q1 = v14 v34 v12 v23 Q2 = emptyConsider v14 no more incoming edges with w lt 1Q1 = v34 v12 v23 Q2 = v14
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Example
v12
500v23
50
v14
3000
v34
1000
v34
1000
v34
150
v34
150
05
50
10
0101 2
v12 v23
v14 v34
Q1 = v34 v12 v23 Q2 = v14
Consider v34 select the edge v23 rarr v34
Recompute cost cost(v34) = 50 lowast 100 lowast 002 + 50 = 150Move to EST Update WDJGQ1 = v12 v34 v23 Q2 = v14
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Example
v12
500v12
500v23
50v23
50
v14
3000
v34
150
v34
150
v34
1000
50
10
v12 v23
v14 v34
Q1 = v12 v34 v23 Q2 = v14
Consider v12 no edgesv34 v23 no incoming edges with w lt 1Q1 = empty Q2 = v23 v34 v12 v14
End of Step 1
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Example
v12
500v23
50
v14
3000
v34
150
v34
1000
50
10
v12 v23
v14 v34
Q2 = v23 v34 v12 v14
Consider v23 edge v14 rarr v23
Adding the edge would not violate EST conditionsAdd edge to ESTDone
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming
Dynamic Programming
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming Overview
Overview
I generate optimal join trees bottom up
I start from optimal join trees of size one (relations)
I build larger join trees by (re-)using optimal solutions for smaller sizes
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming Overview
First Approach DPsizeLinear [2]
I Enumerate increasing in size
I Generate linear trees by adding a single relation at a time
ModificationsExtensions
I enumerate in integer order
I generate bushy trees by considering all pairs of subproblems
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming Example
Example
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming Example
R2
10
R1
10
R3
10
R4
10
01
05
0602
Query Optimization Exercise Session 6 November 27 2017
Homework
I Enumerate connected-subgraph-complement pairs
I Query Simplification
I Reordering constraints for non-inner joins
Query Optimization Exercise Session 6 November 27 2017
Lecture Evaluation
I Remember to bring your laptop for the lecture evaluation next week
Query Optimization Exercise Session 6 November 27 2017
Info
I Slides and exercises dbintumdeteachingws1718queryopt
I Send any questions comments solutions to exercises etc to radkeintumde
I Exercise due 9 AM December 4
Query Optimization Exercise Session 6 November 27 2017
References
[1] C Lee C Shih and Y ChenOptimizing large join queries using A graph-based approachIEEE Trans Knowl Data Eng 13(2)298ndash315 2001
[2] P G Selinger M M Astrahan D D Chamberlin R A Lorie and T G PriceAccess path selection in a relational database management systemIn Proceedings of the 1979 ACM SIGMOD International Conference on Management ofData Boston Massachusetts May 30 - June 1 pages 23ndash34 1979
Query Optimization Exercise Session 6 November 27 2017
- Maximum Value Precedence (MVP)
-
- Weighted Directed Join Graph (WDJG)
- Effective Spanning Tree (EST)
- MVP - informally
- Example
-
- Dynamic Programming
-
- Overview
- Example
-
- Homework
- Lecture Evaluation
- Info
- References
-
![Page 11: Query Optimization: Exercise · 2017. 11. 27. · I node costs: C out of the join v 12 500 23 50 v 14 5000 v 34 1000 5 0:5 0:5 50 10 1 2 Query Optimization: Exercise Session 6 November](https://reader036.fdocuments.us/reader036/viewer/2022071301/609dd6ee5426c42b823cc545/html5/thumbnails/11.jpg)
Maximum Value Precedence (MVP) Example
v12
500v23
50
v14
3000
v34
1000
v34
1000
v34
150
v34
150
05
50
10
0101 2
v12 v23
v14 v34
Q1 = v34 v12 v23 Q2 = v14
Consider v34 select the edge v23 rarr v34
Recompute cost cost(v34) = 50 lowast 100 lowast 002 + 50 = 150Move to EST Update WDJGQ1 = v12 v34 v23 Q2 = v14
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Example
v12
500v12
500v23
50v23
50
v14
3000
v34
150
v34
150
v34
1000
50
10
v12 v23
v14 v34
Q1 = v12 v34 v23 Q2 = v14
Consider v12 no edgesv34 v23 no incoming edges with w lt 1Q1 = empty Q2 = v23 v34 v12 v14
End of Step 1
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Example
v12
500v23
50
v14
3000
v34
150
v34
1000
50
10
v12 v23
v14 v34
Q2 = v23 v34 v12 v14
Consider v23 edge v14 rarr v23
Adding the edge would not violate EST conditionsAdd edge to ESTDone
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming
Dynamic Programming
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming Overview
Overview
I generate optimal join trees bottom up
I start from optimal join trees of size one (relations)
I build larger join trees by (re-)using optimal solutions for smaller sizes
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming Overview
First Approach DPsizeLinear [2]
I Enumerate increasing in size
I Generate linear trees by adding a single relation at a time
ModificationsExtensions
I enumerate in integer order
I generate bushy trees by considering all pairs of subproblems
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming Example
Example
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming Example
R2
10
R1
10
R3
10
R4
10
01
05
0602
Query Optimization Exercise Session 6 November 27 2017
Homework
I Enumerate connected-subgraph-complement pairs
I Query Simplification
I Reordering constraints for non-inner joins
Query Optimization Exercise Session 6 November 27 2017
Lecture Evaluation
I Remember to bring your laptop for the lecture evaluation next week
Query Optimization Exercise Session 6 November 27 2017
Info
I Slides and exercises dbintumdeteachingws1718queryopt
I Send any questions comments solutions to exercises etc to radkeintumde
I Exercise due 9 AM December 4
Query Optimization Exercise Session 6 November 27 2017
References
[1] C Lee C Shih and Y ChenOptimizing large join queries using A graph-based approachIEEE Trans Knowl Data Eng 13(2)298ndash315 2001
[2] P G Selinger M M Astrahan D D Chamberlin R A Lorie and T G PriceAccess path selection in a relational database management systemIn Proceedings of the 1979 ACM SIGMOD International Conference on Management ofData Boston Massachusetts May 30 - June 1 pages 23ndash34 1979
Query Optimization Exercise Session 6 November 27 2017
- Maximum Value Precedence (MVP)
-
- Weighted Directed Join Graph (WDJG)
- Effective Spanning Tree (EST)
- MVP - informally
- Example
-
- Dynamic Programming
-
- Overview
- Example
-
- Homework
- Lecture Evaluation
- Info
- References
-
![Page 12: Query Optimization: Exercise · 2017. 11. 27. · I node costs: C out of the join v 12 500 23 50 v 14 5000 v 34 1000 5 0:5 0:5 50 10 1 2 Query Optimization: Exercise Session 6 November](https://reader036.fdocuments.us/reader036/viewer/2022071301/609dd6ee5426c42b823cc545/html5/thumbnails/12.jpg)
Maximum Value Precedence (MVP) Example
v12
500v12
500v23
50v23
50
v14
3000
v34
150
v34
150
v34
1000
50
10
v12 v23
v14 v34
Q1 = v12 v34 v23 Q2 = v14
Consider v12 no edgesv34 v23 no incoming edges with w lt 1Q1 = empty Q2 = v23 v34 v12 v14
End of Step 1
Query Optimization Exercise Session 6 November 27 2017
Maximum Value Precedence (MVP) Example
v12
500v23
50
v14
3000
v34
150
v34
1000
50
10
v12 v23
v14 v34
Q2 = v23 v34 v12 v14
Consider v23 edge v14 rarr v23
Adding the edge would not violate EST conditionsAdd edge to ESTDone
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming
Dynamic Programming
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming Overview
Overview
I generate optimal join trees bottom up
I start from optimal join trees of size one (relations)
I build larger join trees by (re-)using optimal solutions for smaller sizes
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming Overview
First Approach DPsizeLinear [2]
I Enumerate increasing in size
I Generate linear trees by adding a single relation at a time
ModificationsExtensions
I enumerate in integer order
I generate bushy trees by considering all pairs of subproblems
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming Example
Example
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming Example
R2
10
R1
10
R3
10
R4
10
01
05
0602
Query Optimization Exercise Session 6 November 27 2017
Homework
I Enumerate connected-subgraph-complement pairs
I Query Simplification
I Reordering constraints for non-inner joins
Query Optimization Exercise Session 6 November 27 2017
Lecture Evaluation
I Remember to bring your laptop for the lecture evaluation next week
Query Optimization Exercise Session 6 November 27 2017
Info
I Slides and exercises dbintumdeteachingws1718queryopt
I Send any questions comments solutions to exercises etc to radkeintumde
I Exercise due 9 AM December 4
Query Optimization Exercise Session 6 November 27 2017
References
[1] C Lee C Shih and Y ChenOptimizing large join queries using A graph-based approachIEEE Trans Knowl Data Eng 13(2)298ndash315 2001
[2] P G Selinger M M Astrahan D D Chamberlin R A Lorie and T G PriceAccess path selection in a relational database management systemIn Proceedings of the 1979 ACM SIGMOD International Conference on Management ofData Boston Massachusetts May 30 - June 1 pages 23ndash34 1979
Query Optimization Exercise Session 6 November 27 2017
- Maximum Value Precedence (MVP)
-
- Weighted Directed Join Graph (WDJG)
- Effective Spanning Tree (EST)
- MVP - informally
- Example
-
- Dynamic Programming
-
- Overview
- Example
-
- Homework
- Lecture Evaluation
- Info
- References
-
![Page 13: Query Optimization: Exercise · 2017. 11. 27. · I node costs: C out of the join v 12 500 23 50 v 14 5000 v 34 1000 5 0:5 0:5 50 10 1 2 Query Optimization: Exercise Session 6 November](https://reader036.fdocuments.us/reader036/viewer/2022071301/609dd6ee5426c42b823cc545/html5/thumbnails/13.jpg)
Maximum Value Precedence (MVP) Example
v12
500v23
50
v14
3000
v34
150
v34
1000
50
10
v12 v23
v14 v34
Q2 = v23 v34 v12 v14
Consider v23 edge v14 rarr v23
Adding the edge would not violate EST conditionsAdd edge to ESTDone
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming
Dynamic Programming
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming Overview
Overview
I generate optimal join trees bottom up
I start from optimal join trees of size one (relations)
I build larger join trees by (re-)using optimal solutions for smaller sizes
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming Overview
First Approach DPsizeLinear [2]
I Enumerate increasing in size
I Generate linear trees by adding a single relation at a time
ModificationsExtensions
I enumerate in integer order
I generate bushy trees by considering all pairs of subproblems
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming Example
Example
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming Example
R2
10
R1
10
R3
10
R4
10
01
05
0602
Query Optimization Exercise Session 6 November 27 2017
Homework
I Enumerate connected-subgraph-complement pairs
I Query Simplification
I Reordering constraints for non-inner joins
Query Optimization Exercise Session 6 November 27 2017
Lecture Evaluation
I Remember to bring your laptop for the lecture evaluation next week
Query Optimization Exercise Session 6 November 27 2017
Info
I Slides and exercises dbintumdeteachingws1718queryopt
I Send any questions comments solutions to exercises etc to radkeintumde
I Exercise due 9 AM December 4
Query Optimization Exercise Session 6 November 27 2017
References
[1] C Lee C Shih and Y ChenOptimizing large join queries using A graph-based approachIEEE Trans Knowl Data Eng 13(2)298ndash315 2001
[2] P G Selinger M M Astrahan D D Chamberlin R A Lorie and T G PriceAccess path selection in a relational database management systemIn Proceedings of the 1979 ACM SIGMOD International Conference on Management ofData Boston Massachusetts May 30 - June 1 pages 23ndash34 1979
Query Optimization Exercise Session 6 November 27 2017
- Maximum Value Precedence (MVP)
-
- Weighted Directed Join Graph (WDJG)
- Effective Spanning Tree (EST)
- MVP - informally
- Example
-
- Dynamic Programming
-
- Overview
- Example
-
- Homework
- Lecture Evaluation
- Info
- References
-
![Page 14: Query Optimization: Exercise · 2017. 11. 27. · I node costs: C out of the join v 12 500 23 50 v 14 5000 v 34 1000 5 0:5 0:5 50 10 1 2 Query Optimization: Exercise Session 6 November](https://reader036.fdocuments.us/reader036/viewer/2022071301/609dd6ee5426c42b823cc545/html5/thumbnails/14.jpg)
Dynamic Programming
Dynamic Programming
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming Overview
Overview
I generate optimal join trees bottom up
I start from optimal join trees of size one (relations)
I build larger join trees by (re-)using optimal solutions for smaller sizes
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming Overview
First Approach DPsizeLinear [2]
I Enumerate increasing in size
I Generate linear trees by adding a single relation at a time
ModificationsExtensions
I enumerate in integer order
I generate bushy trees by considering all pairs of subproblems
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming Example
Example
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming Example
R2
10
R1
10
R3
10
R4
10
01
05
0602
Query Optimization Exercise Session 6 November 27 2017
Homework
I Enumerate connected-subgraph-complement pairs
I Query Simplification
I Reordering constraints for non-inner joins
Query Optimization Exercise Session 6 November 27 2017
Lecture Evaluation
I Remember to bring your laptop for the lecture evaluation next week
Query Optimization Exercise Session 6 November 27 2017
Info
I Slides and exercises dbintumdeteachingws1718queryopt
I Send any questions comments solutions to exercises etc to radkeintumde
I Exercise due 9 AM December 4
Query Optimization Exercise Session 6 November 27 2017
References
[1] C Lee C Shih and Y ChenOptimizing large join queries using A graph-based approachIEEE Trans Knowl Data Eng 13(2)298ndash315 2001
[2] P G Selinger M M Astrahan D D Chamberlin R A Lorie and T G PriceAccess path selection in a relational database management systemIn Proceedings of the 1979 ACM SIGMOD International Conference on Management ofData Boston Massachusetts May 30 - June 1 pages 23ndash34 1979
Query Optimization Exercise Session 6 November 27 2017
- Maximum Value Precedence (MVP)
-
- Weighted Directed Join Graph (WDJG)
- Effective Spanning Tree (EST)
- MVP - informally
- Example
-
- Dynamic Programming
-
- Overview
- Example
-
- Homework
- Lecture Evaluation
- Info
- References
-
![Page 15: Query Optimization: Exercise · 2017. 11. 27. · I node costs: C out of the join v 12 500 23 50 v 14 5000 v 34 1000 5 0:5 0:5 50 10 1 2 Query Optimization: Exercise Session 6 November](https://reader036.fdocuments.us/reader036/viewer/2022071301/609dd6ee5426c42b823cc545/html5/thumbnails/15.jpg)
Dynamic Programming Overview
Overview
I generate optimal join trees bottom up
I start from optimal join trees of size one (relations)
I build larger join trees by (re-)using optimal solutions for smaller sizes
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming Overview
First Approach DPsizeLinear [2]
I Enumerate increasing in size
I Generate linear trees by adding a single relation at a time
ModificationsExtensions
I enumerate in integer order
I generate bushy trees by considering all pairs of subproblems
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming Example
Example
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming Example
R2
10
R1
10
R3
10
R4
10
01
05
0602
Query Optimization Exercise Session 6 November 27 2017
Homework
I Enumerate connected-subgraph-complement pairs
I Query Simplification
I Reordering constraints for non-inner joins
Query Optimization Exercise Session 6 November 27 2017
Lecture Evaluation
I Remember to bring your laptop for the lecture evaluation next week
Query Optimization Exercise Session 6 November 27 2017
Info
I Slides and exercises dbintumdeteachingws1718queryopt
I Send any questions comments solutions to exercises etc to radkeintumde
I Exercise due 9 AM December 4
Query Optimization Exercise Session 6 November 27 2017
References
[1] C Lee C Shih and Y ChenOptimizing large join queries using A graph-based approachIEEE Trans Knowl Data Eng 13(2)298ndash315 2001
[2] P G Selinger M M Astrahan D D Chamberlin R A Lorie and T G PriceAccess path selection in a relational database management systemIn Proceedings of the 1979 ACM SIGMOD International Conference on Management ofData Boston Massachusetts May 30 - June 1 pages 23ndash34 1979
Query Optimization Exercise Session 6 November 27 2017
- Maximum Value Precedence (MVP)
-
- Weighted Directed Join Graph (WDJG)
- Effective Spanning Tree (EST)
- MVP - informally
- Example
-
- Dynamic Programming
-
- Overview
- Example
-
- Homework
- Lecture Evaluation
- Info
- References
-
![Page 16: Query Optimization: Exercise · 2017. 11. 27. · I node costs: C out of the join v 12 500 23 50 v 14 5000 v 34 1000 5 0:5 0:5 50 10 1 2 Query Optimization: Exercise Session 6 November](https://reader036.fdocuments.us/reader036/viewer/2022071301/609dd6ee5426c42b823cc545/html5/thumbnails/16.jpg)
Dynamic Programming Overview
First Approach DPsizeLinear [2]
I Enumerate increasing in size
I Generate linear trees by adding a single relation at a time
ModificationsExtensions
I enumerate in integer order
I generate bushy trees by considering all pairs of subproblems
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming Example
Example
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming Example
R2
10
R1
10
R3
10
R4
10
01
05
0602
Query Optimization Exercise Session 6 November 27 2017
Homework
I Enumerate connected-subgraph-complement pairs
I Query Simplification
I Reordering constraints for non-inner joins
Query Optimization Exercise Session 6 November 27 2017
Lecture Evaluation
I Remember to bring your laptop for the lecture evaluation next week
Query Optimization Exercise Session 6 November 27 2017
Info
I Slides and exercises dbintumdeteachingws1718queryopt
I Send any questions comments solutions to exercises etc to radkeintumde
I Exercise due 9 AM December 4
Query Optimization Exercise Session 6 November 27 2017
References
[1] C Lee C Shih and Y ChenOptimizing large join queries using A graph-based approachIEEE Trans Knowl Data Eng 13(2)298ndash315 2001
[2] P G Selinger M M Astrahan D D Chamberlin R A Lorie and T G PriceAccess path selection in a relational database management systemIn Proceedings of the 1979 ACM SIGMOD International Conference on Management ofData Boston Massachusetts May 30 - June 1 pages 23ndash34 1979
Query Optimization Exercise Session 6 November 27 2017
- Maximum Value Precedence (MVP)
-
- Weighted Directed Join Graph (WDJG)
- Effective Spanning Tree (EST)
- MVP - informally
- Example
-
- Dynamic Programming
-
- Overview
- Example
-
- Homework
- Lecture Evaluation
- Info
- References
-
![Page 17: Query Optimization: Exercise · 2017. 11. 27. · I node costs: C out of the join v 12 500 23 50 v 14 5000 v 34 1000 5 0:5 0:5 50 10 1 2 Query Optimization: Exercise Session 6 November](https://reader036.fdocuments.us/reader036/viewer/2022071301/609dd6ee5426c42b823cc545/html5/thumbnails/17.jpg)
Dynamic Programming Example
Example
Query Optimization Exercise Session 6 November 27 2017
Dynamic Programming Example
R2
10
R1
10
R3
10
R4
10
01
05
0602
Query Optimization Exercise Session 6 November 27 2017
Homework
I Enumerate connected-subgraph-complement pairs
I Query Simplification
I Reordering constraints for non-inner joins
Query Optimization Exercise Session 6 November 27 2017
Lecture Evaluation
I Remember to bring your laptop for the lecture evaluation next week
Query Optimization Exercise Session 6 November 27 2017
Info
I Slides and exercises dbintumdeteachingws1718queryopt
I Send any questions comments solutions to exercises etc to radkeintumde
I Exercise due 9 AM December 4
Query Optimization Exercise Session 6 November 27 2017
References
[1] C Lee C Shih and Y ChenOptimizing large join queries using A graph-based approachIEEE Trans Knowl Data Eng 13(2)298ndash315 2001
[2] P G Selinger M M Astrahan D D Chamberlin R A Lorie and T G PriceAccess path selection in a relational database management systemIn Proceedings of the 1979 ACM SIGMOD International Conference on Management ofData Boston Massachusetts May 30 - June 1 pages 23ndash34 1979
Query Optimization Exercise Session 6 November 27 2017
- Maximum Value Precedence (MVP)
-
- Weighted Directed Join Graph (WDJG)
- Effective Spanning Tree (EST)
- MVP - informally
- Example
-
- Dynamic Programming
-
- Overview
- Example
-
- Homework
- Lecture Evaluation
- Info
- References
-
![Page 18: Query Optimization: Exercise · 2017. 11. 27. · I node costs: C out of the join v 12 500 23 50 v 14 5000 v 34 1000 5 0:5 0:5 50 10 1 2 Query Optimization: Exercise Session 6 November](https://reader036.fdocuments.us/reader036/viewer/2022071301/609dd6ee5426c42b823cc545/html5/thumbnails/18.jpg)
Dynamic Programming Example
R2
10
R1
10
R3
10
R4
10
01
05
0602
Query Optimization Exercise Session 6 November 27 2017
Homework
I Enumerate connected-subgraph-complement pairs
I Query Simplification
I Reordering constraints for non-inner joins
Query Optimization Exercise Session 6 November 27 2017
Lecture Evaluation
I Remember to bring your laptop for the lecture evaluation next week
Query Optimization Exercise Session 6 November 27 2017
Info
I Slides and exercises dbintumdeteachingws1718queryopt
I Send any questions comments solutions to exercises etc to radkeintumde
I Exercise due 9 AM December 4
Query Optimization Exercise Session 6 November 27 2017
References
[1] C Lee C Shih and Y ChenOptimizing large join queries using A graph-based approachIEEE Trans Knowl Data Eng 13(2)298ndash315 2001
[2] P G Selinger M M Astrahan D D Chamberlin R A Lorie and T G PriceAccess path selection in a relational database management systemIn Proceedings of the 1979 ACM SIGMOD International Conference on Management ofData Boston Massachusetts May 30 - June 1 pages 23ndash34 1979
Query Optimization Exercise Session 6 November 27 2017
- Maximum Value Precedence (MVP)
-
- Weighted Directed Join Graph (WDJG)
- Effective Spanning Tree (EST)
- MVP - informally
- Example
-
- Dynamic Programming
-
- Overview
- Example
-
- Homework
- Lecture Evaluation
- Info
- References
-
![Page 19: Query Optimization: Exercise · 2017. 11. 27. · I node costs: C out of the join v 12 500 23 50 v 14 5000 v 34 1000 5 0:5 0:5 50 10 1 2 Query Optimization: Exercise Session 6 November](https://reader036.fdocuments.us/reader036/viewer/2022071301/609dd6ee5426c42b823cc545/html5/thumbnails/19.jpg)
Homework
I Enumerate connected-subgraph-complement pairs
I Query Simplification
I Reordering constraints for non-inner joins
Query Optimization Exercise Session 6 November 27 2017
Lecture Evaluation
I Remember to bring your laptop for the lecture evaluation next week
Query Optimization Exercise Session 6 November 27 2017
Info
I Slides and exercises dbintumdeteachingws1718queryopt
I Send any questions comments solutions to exercises etc to radkeintumde
I Exercise due 9 AM December 4
Query Optimization Exercise Session 6 November 27 2017
References
[1] C Lee C Shih and Y ChenOptimizing large join queries using A graph-based approachIEEE Trans Knowl Data Eng 13(2)298ndash315 2001
[2] P G Selinger M M Astrahan D D Chamberlin R A Lorie and T G PriceAccess path selection in a relational database management systemIn Proceedings of the 1979 ACM SIGMOD International Conference on Management ofData Boston Massachusetts May 30 - June 1 pages 23ndash34 1979
Query Optimization Exercise Session 6 November 27 2017
- Maximum Value Precedence (MVP)
-
- Weighted Directed Join Graph (WDJG)
- Effective Spanning Tree (EST)
- MVP - informally
- Example
-
- Dynamic Programming
-
- Overview
- Example
-
- Homework
- Lecture Evaluation
- Info
- References
-
![Page 20: Query Optimization: Exercise · 2017. 11. 27. · I node costs: C out of the join v 12 500 23 50 v 14 5000 v 34 1000 5 0:5 0:5 50 10 1 2 Query Optimization: Exercise Session 6 November](https://reader036.fdocuments.us/reader036/viewer/2022071301/609dd6ee5426c42b823cc545/html5/thumbnails/20.jpg)
Lecture Evaluation
I Remember to bring your laptop for the lecture evaluation next week
Query Optimization Exercise Session 6 November 27 2017
Info
I Slides and exercises dbintumdeteachingws1718queryopt
I Send any questions comments solutions to exercises etc to radkeintumde
I Exercise due 9 AM December 4
Query Optimization Exercise Session 6 November 27 2017
References
[1] C Lee C Shih and Y ChenOptimizing large join queries using A graph-based approachIEEE Trans Knowl Data Eng 13(2)298ndash315 2001
[2] P G Selinger M M Astrahan D D Chamberlin R A Lorie and T G PriceAccess path selection in a relational database management systemIn Proceedings of the 1979 ACM SIGMOD International Conference on Management ofData Boston Massachusetts May 30 - June 1 pages 23ndash34 1979
Query Optimization Exercise Session 6 November 27 2017
- Maximum Value Precedence (MVP)
-
- Weighted Directed Join Graph (WDJG)
- Effective Spanning Tree (EST)
- MVP - informally
- Example
-
- Dynamic Programming
-
- Overview
- Example
-
- Homework
- Lecture Evaluation
- Info
- References
-
![Page 21: Query Optimization: Exercise · 2017. 11. 27. · I node costs: C out of the join v 12 500 23 50 v 14 5000 v 34 1000 5 0:5 0:5 50 10 1 2 Query Optimization: Exercise Session 6 November](https://reader036.fdocuments.us/reader036/viewer/2022071301/609dd6ee5426c42b823cc545/html5/thumbnails/21.jpg)
Info
I Slides and exercises dbintumdeteachingws1718queryopt
I Send any questions comments solutions to exercises etc to radkeintumde
I Exercise due 9 AM December 4
Query Optimization Exercise Session 6 November 27 2017
References
[1] C Lee C Shih and Y ChenOptimizing large join queries using A graph-based approachIEEE Trans Knowl Data Eng 13(2)298ndash315 2001
[2] P G Selinger M M Astrahan D D Chamberlin R A Lorie and T G PriceAccess path selection in a relational database management systemIn Proceedings of the 1979 ACM SIGMOD International Conference on Management ofData Boston Massachusetts May 30 - June 1 pages 23ndash34 1979
Query Optimization Exercise Session 6 November 27 2017
- Maximum Value Precedence (MVP)
-
- Weighted Directed Join Graph (WDJG)
- Effective Spanning Tree (EST)
- MVP - informally
- Example
-
- Dynamic Programming
-
- Overview
- Example
-
- Homework
- Lecture Evaluation
- Info
- References
-
![Page 22: Query Optimization: Exercise · 2017. 11. 27. · I node costs: C out of the join v 12 500 23 50 v 14 5000 v 34 1000 5 0:5 0:5 50 10 1 2 Query Optimization: Exercise Session 6 November](https://reader036.fdocuments.us/reader036/viewer/2022071301/609dd6ee5426c42b823cc545/html5/thumbnails/22.jpg)
References
[1] C Lee C Shih and Y ChenOptimizing large join queries using A graph-based approachIEEE Trans Knowl Data Eng 13(2)298ndash315 2001
[2] P G Selinger M M Astrahan D D Chamberlin R A Lorie and T G PriceAccess path selection in a relational database management systemIn Proceedings of the 1979 ACM SIGMOD International Conference on Management ofData Boston Massachusetts May 30 - June 1 pages 23ndash34 1979
Query Optimization Exercise Session 6 November 27 2017
- Maximum Value Precedence (MVP)
-
- Weighted Directed Join Graph (WDJG)
- Effective Spanning Tree (EST)
- MVP - informally
- Example
-
- Dynamic Programming
-
- Overview
- Example
-
- Homework
- Lecture Evaluation
- Info
- References
-