示例#1
0
        public IEnumerable <ShowPlan> GetShowPlanSteps()
        {
            var bindingResult = Binder.Bind(SyntaxTree.Root, DataContext);

            if (GetDiagnostics(bindingResult).Any())
            {
                yield break;
            }

            var inputQuery = GetBoundQuery(bindingResult.BoundRoot);

            yield return(ShowPlanBuilder.Build(Resources.ShowPlanUnoptimized, inputQuery));

            var relation = inputQuery.Relation;

            foreach (var rewriter in Optimizer.GetOptimizationSteps())
            {
                var step = rewriter.RewriteRelation(relation);
                if (step != relation)
                {
                    var stepName  = string.Format(Resources.ShowPlanStepFmt, rewriter.GetType().Name);
                    var stepQuery = new BoundQuery(step, inputQuery.OutputColumns);
                    yield return(ShowPlanBuilder.Build(stepName, stepQuery));
                }

                relation = step;
            }

            var ouputQuery = new BoundQuery(relation, inputQuery.OutputColumns);

            yield return(ShowPlanBuilder.Build(Resources.ShowPlanOptimized, ouputQuery));
        }
示例#2
0
        internal static ShowPlan Build(AlgebraNode root)
        {
            ShowPlanElement rootElement = ShowPlanBuilder.Convert(root);

            return(new ShowPlan(rootElement));
        }