Upload
ryan-marcus
View
37
Download
4
Tags:
Embed Size (px)
Citation preview
Execution Plan Compiler
Brionne Godby Rachel Leeman-Munk
Ryan Marcus
Motivation
● DevelOPs lets optimizers build execution plans
Motivation
● DevelOPs lets optimizers build physical plans
● … but there’s no way of testing those plans!
Motivation
● DevelOPs lets optimizers build physical plans
● … but there’s no way of testing those plans!
● Enter: EPtoSQL!
SQL Server
● Microsoft SQL Server lets you force join order○ OPTION(FORCE ORDER)
● And join types…○ SELECT * FROM t1 MERGE JOIN t2 ON ...
DevelOPs Physical Plans
Merge Join
Loop Join
table1 table2
table3
DevelOPs Physical Plans
Merge Join
Loop Join
table1 table2
table3
PMJOIN(attr1 = attr2, PNLJOIN(a3 = a4, PTABLE(table1), PTABLE(table2) ), PTABLE(table3))
Translating Physical PlansPMJOIN(attr1 = attr2, PNLJOIN(a3 = a4, PTABLE(table1), PTABLE(table2) ), PTABLE(table3))
SELECT * FROM table2INNER LOOP JOIN table1 ON a3 = a4 INNER MERGE JOIN table3 ON attr1 = attr2 OPTION(FORCE ORDER);
Translating Physical PlansPMJOIN(attr1 = attr2, PNLJOIN(a3 = a4, PTABLE(table1), PTABLE(table2) ), PTABLE(table3))
SELECT * FROM table2INNER LOOP JOIN table1 ON a3 = a4 INNER MERGE JOIN table3 ON attr1 = attr2 OPTION(FORCE ORDER);
Translating Physical PlansPMJOIN(attr1 = attr2, PNLJOIN(a3 = a4, PTABLE(table1), PTABLE(table2) ), PTABLE(table3))
SELECT * FROM table2INNER LOOP JOIN table1 ON a3 = a4 INNER MERGE JOIN table3 ON attr1 = attr2 OPTION(FORCE ORDER);
Translating Physical Plans
● Some complications○ Selection over join with same attributes○ Join over selection with same attributes
Translating Physical Plans
● Some complications○ Selection over join with same attributes○ Join over selection with same attributes
● Subexpression elimination
Subexpression Elimination
Merge Join
Loop Join
table1 table2
table3
Subexpression Elimination
Merge Join
Loop Join
table1 table2
table3
Merge Join
table3
#T1
General Procedure
General Procedure
Semantics after IR?
General Procedure
Subexpression elimination
Semantics after IR?
General Procedure
Subexpression elimination
Everything valid if each subexpression
valid
GPL’d!
● Code on GitHub○ https://github.com/RyanMarcus/DevelOPSToSQLServerCompiler