on master help sign in
add ":p" to show the execution plan
3e7015fAgentM
README.markdown+6
@@ -59,6 +59,12 @@ fromList []
59```
59```
60which displays database constraints.
60which displays database constraints.
61
61
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+
623. expressions which modify the database context such as:
683. expressions which modify the database context such as:
63
69
64 ```
70 ```
TutorialDInterpreter.hs+13
@@ -248,6 +248,7 @@ data TutorialDOperator where
248 ShowRelation :: RelationalExpr -> TutorialDOperator
248 ShowRelation :: RelationalExpr -> TutorialDOperator
249 ShowRelationType :: RelationalExpr -> TutorialDOperator
249 ShowRelationType :: RelationalExpr -> TutorialDOperator
250 ShowConstraint :: String -> TutorialDOperator
250 ShowConstraint :: String -> TutorialDOperator
251+ ShowPlan :: DatabaseExpr -> TutorialDOperator
251 Quit :: TutorialDOperator
252 Quit :: TutorialDOperator
252 deriving (Show)
253 deriving (Show)
253
254
@@ -263,6 +264,12 @@ showRelP = do
263 expr <- relExpr
264 expr <- relExpr
264 return $ ShowRelation expr
265 return $ ShowRelation expr
265
266
267+showPlanP :: Parser TutorialDOperator
268+showPlanP = do
269+ reservedOp ":p"
270+ expr <- databaseExpr
271+ return $ ShowPlan expr
272+
266quitP :: Parser TutorialDOperator
273quitP :: Parser TutorialDOperator
267quitP = do
274quitP = do
268 reservedOp ":q"
275 reservedOp ":q"
@@ -278,6 +285,7 @@ interpreterOps :: Parser TutorialDOperator
278interpreterOps = typeP
285interpreterOps = typeP
279 <|> showRelP
286 <|> showRelP
280 <|> showConstraintsP
287 <|> showConstraintsP
288+ <|> showPlanP
281 <|> quitP
289 <|> quitP
282
290
283showRelationAttributes :: Relation -> String
291showRelationAttributes :: Relation -> String
@@ -312,6 +320,11 @@ evalTutorialDOp context (ShowConstraint name) = do
312 "" -> deps
320 "" -> deps
313 name -> HS.filter (\(InclusionDependency n _ _) -> n == name) deps
321 name -> HS.filter (\(InclusionDependency n _ _) -> n == name) deps
314
322
323+evalTutorialDOp context (ShowPlan dbExpr) = do
324+ DisplayResult $ show plan
325+ where
326+ plan = evalState (applyStaticDatabaseOptimization dbExpr) context
327+
315evalTutorialDOp context (Quit) = QuitResult
328evalTutorialDOp context (Quit) = QuitResult
316
329
317example1 = "relA {a,b, c}"
330example1 = "relA {a,b, c}"