on master help sign in
add ":p" to show the execution plan
commit3e7015f37d4695392117344b574f9ce26bbf475e authorAgentM <agentm@themactionfaction.com> dateThu 5 Feb 2015, 16:54 (12 years ago) parente9350a5
2 files changed+19
README.markdown+6 TutorialDInterpreter.hs+13
README.markdown+6
@@ -59,6 +59,12 @@ fromList []
5959```
6060which displays database constraints.
6161
62+ ```
63+TutorialD: :p x:=S{CITY,S#,SNAME,STATUS}
64+Right (Assign "x" (RelationVariable "S"))
65+```
66+which displays the optimized execution plan which would have been executed to evaluate the expression.
67+
62683. expressions which modify the database context such as:
6369
6470 ```
TutorialDInterpreter.hs+13
@@ -248,6 +248,7 @@ data TutorialDOperator where
248248 ShowRelation :: RelationalExpr -> TutorialDOperator
249249 ShowRelationType :: RelationalExpr -> TutorialDOperator
250250 ShowConstraint :: String -> TutorialDOperator
251+ ShowPlan :: DatabaseExpr -> TutorialDOperator
251252 Quit :: TutorialDOperator
252253 deriving (Show)
253254
@@ -263,6 +264,12 @@ showRelP = do
263264 expr <- relExpr
264265 return $ ShowRelation expr
265266
267+showPlanP :: Parser TutorialDOperator
268+showPlanP = do
269+ reservedOp ":p"
270+ expr <- databaseExpr
271+ return $ ShowPlan expr
272+
266273quitP :: Parser TutorialDOperator
267274quitP = do
268275 reservedOp ":q"
@@ -278,6 +285,7 @@ interpreterOps :: Parser TutorialDOperator
278285interpreterOps = typeP
279286 <|> showRelP
280287 <|> showConstraintsP
288+ <|> showPlanP
281289 <|> quitP
282290
283291showRelationAttributes :: Relation -> String
@@ -312,6 +320,11 @@ evalTutorialDOp context (ShowConstraint name) = do
312320 "" -> deps
313321 name -> HS.filter (\(InclusionDependency n _ _) -> n == name) deps
314322
323+evalTutorialDOp context (ShowPlan dbExpr) = do
324+ DisplayResult $ show plan
325+ where
326+ plan = evalState (applyStaticDatabaseOptimization dbExpr) context
327+
315328evalTutorialDOp context (Quit) = QuitResult
316329
317330example1 = "relA {a,b, c}"