public override AlgebraNode VisitResultAlgebraNode(ResultAlgebraNode node) { ShowPlanElement inputElement = ConvertNode(node.Input); PropertyListBuilder propertyListBuilder = new PropertyListBuilder(); propertyListBuilder.Begin(Resources.ShowPlanGroupOutputList); for (int i = 0; i < node.OutputList.Length; i++) { propertyListBuilder.Begin(); propertyListBuilder.SetGroupValue(String.Format(CultureInfo.InvariantCulture, "{0} AS {1}", node.OutputList[i].Name, node.ColumnNames[i])); WriteRowBufferEntry(propertyListBuilder, node.OutputList[i]); propertyListBuilder.Write(Resources.ShowPlanKeyOutputName, node.ColumnNames[i]); propertyListBuilder.End(); } propertyListBuilder.End(); IList <ShowPlanProperty> properties = propertyListBuilder.ToList(); ShowPlanElement element = new ShowPlanElement(ShowPlanOperator.Select, properties, inputElement); _currentElement = element; return(node); }
public override AlgebraNode VisitTopAlgebraNode(TopAlgebraNode node) { ShowPlanElement inputElement = ConvertNode(node.Input); PropertyListBuilder propertyListBuilder = new PropertyListBuilder(); AddRowBufferEntries(propertyListBuilder, Resources.ShowPlanGroupOutputList, node.OutputList); AddStatistics(propertyListBuilder, node.StatisticsIterator); propertyListBuilder.Write(Resources.ShowPlanKeyLimit, node.Limit.ToString(CultureInfo.InvariantCulture)); if (node.TieEntries == null) { propertyListBuilder.Write(Resources.ShowPlanKeyWithTies, Boolean.FalseString); } else { propertyListBuilder.Write(Resources.ShowPlanKeyWithTies, Boolean.TrueString); AddRowBufferEntries(propertyListBuilder, Resources.ShowPlanGroupTieColumns, node.TieEntries); } IList <ShowPlanProperty> properties = propertyListBuilder.ToList(); ShowPlanElement element = new ShowPlanElement(ShowPlanOperator.Top, properties, inputElement); _currentElement = element; return(node); }
public override AlgebraNode VisitHashMatchAlgebraNode(HashMatchAlgebraNode node) { ShowPlanElement buildElement = ConvertNode(node.Left); ShowPlanElement probeElement = ConvertNode(node.Right); PropertyListBuilder propertyListBuilder = new PropertyListBuilder(); AddRowBufferEntries(propertyListBuilder, Resources.ShowPlanGroupOutputList, node.OutputList); AddStatistics(propertyListBuilder, node.StatisticsIterator); WriteRowBufferEntry(propertyListBuilder, Resources.ShowPlanKeyHashKeysBuild, node.BuildKeyEntry); WriteRowBufferEntry(propertyListBuilder, Resources.ShowPlanKeyHashKeysProbe, node.ProbeEntry); propertyListBuilder.Write(Resources.ShowPlanKeyLogicalOperator, LogicalOperatorToString(node.Op)); if (node.ProbeResidual != null) { propertyListBuilder.Write(Resources.ShowPlanKeyProbeResidual, node.ProbeResidual.GenerateSource()); } IList <ShowPlanProperty> properties = propertyListBuilder.ToList(); ShowPlanElement element = new ShowPlanElement(ShowPlanOperator.HashMatch, properties, buildElement, probeElement); _currentElement = element; return(node); }
private ShowPlanElement ConvertNode(AlgebraNode node) { Visit(node); ShowPlanElement result = _currentElement; _currentElement = null; return(result); }
public override AlgebraNode VisitJoinAlgebraNode(JoinAlgebraNode node) { ShowPlanElement leftElement = ConvertNode(node.Left); ShowPlanElement rightElement = ConvertNode(node.Right); PropertyListBuilder propertyListBuilder = new PropertyListBuilder(); AddRowBufferEntries(propertyListBuilder, Resources.ShowPlanGroupOutputList, node.OutputList); propertyListBuilder.Write(Resources.ShowPlanKeyLogicalOperator, LogicalOperatorToString(node.Op)); AddStatistics(propertyListBuilder, node.StatisticsIterator); if (node.Predicate != null) { propertyListBuilder.Write(Resources.ShowPlanKeyPredicate, node.Predicate.GenerateSource()); } if (node.OuterReferences != null && node.OuterReferences.Length > 0) { AddRowBufferEntries(propertyListBuilder, Resources.ShowPlanGroupOuterReferences, node.OuterReferences); } if (node.ProbeBufferEntry != null) { WriteRowBufferEntry(propertyListBuilder, Resources.ShowPlanKeyProbeColumn, node.ProbeBufferEntry); } if (node.PassthruPredicate != null) { propertyListBuilder.Write(Resources.ShowPlanKeyPassthru, node.PassthruPredicate.GenerateSource()); } // We give a warning if a join has no predicate and no outer reference. // In this case the join would simply multiply the other side. // However, we supppress the warning if any side is known at produce at // most one row. if (node.Predicate == null && (node.OuterReferences == null || node.OuterReferences.Length == 0) && !AstUtil.WillProduceAtMostOneRow(node.Left) && !AstUtil.WillProduceAtMostOneRow(node.Right)) { propertyListBuilder.Write(Resources.ShowPlanKeyWarning, Resources.ShowPlanWarningNoJoinPredicate); } IList <ShowPlanProperty> properties = propertyListBuilder.ToList(); ShowPlanElement element = new ShowPlanElement(ShowPlanOperator.NestedLoops, properties, leftElement, rightElement); _currentElement = element; return(node); }
public override AlgebraNode VisitTableAlgebraNode(TableAlgebraNode node) { PropertyListBuilder propertyListBuilder = new PropertyListBuilder(); propertyListBuilder.Write(Resources.ShowPlanKeyTable, String.Format(CultureInfo.InvariantCulture, "{0} AS {1}", node.TableRefBinding.TableBinding.Name, node.TableRefBinding.Name)); AddRowBufferEntries(propertyListBuilder, Resources.ShowPlanGroupOutputList, node.OutputList); AddStatistics(propertyListBuilder, node.StatisticsIterator); IList <ShowPlanProperty> properties = propertyListBuilder.ToList(); ShowPlanElement element = new ShowPlanElement(ShowPlanOperator.TableScan, properties); _currentElement = element; return(node); }
public override AlgebraNode VisitNullScanAlgebraNode(NullScanAlgebraNode node) { PropertyListBuilder propertyListBuilder = new PropertyListBuilder(); propertyListBuilder.Write(Resources.ShowPlanKeyEmpty, Boolean.TrueString); AddRowBufferEntries(propertyListBuilder, Resources.ShowPlanGroupOutputList, node.OutputList); AddStatistics(propertyListBuilder, node.StatisticsIterator); IList <ShowPlanProperty> properties = propertyListBuilder.ToList(); ShowPlanElement element = new ShowPlanElement(ShowPlanOperator.ConstantScan, properties); _currentElement = element; return(node); }
public override AlgebraNode VisitComputeScalarAlgebraNode(ComputeScalarAlgebraNode node) { ShowPlanElement inputElement = ConvertNode(node.Input); PropertyListBuilder propertyListBuilder = new PropertyListBuilder(); AddRowBufferEntries(propertyListBuilder, Resources.ShowPlanGroupOutputList, node.OutputList); AddStatistics(propertyListBuilder, node.StatisticsIterator); AddDefinedValues(propertyListBuilder, node.DefinedValues); IList<ShowPlanProperty> properties = propertyListBuilder.ToList(); ShowPlanElement element = new ShowPlanElement(ShowPlanOperator.ComputeScalar, properties, inputElement); _currentElement = element; return node; }
public override AlgebraNode VisitAssertAlgebraNode(AssertAlgebraNode node) { ShowPlanElement inputElement = ConvertNode(node.Input); PropertyListBuilder propertyListBuilder = new PropertyListBuilder(); AddRowBufferEntries(propertyListBuilder, Resources.ShowPlanGroupOutputList, node.OutputList); AddStatistics(propertyListBuilder, node.StatisticsIterator); propertyListBuilder.Write(Resources.ShowPlanKeyPredicate, node.Predicate.GenerateSource()); IList<ShowPlanProperty> properties = propertyListBuilder.ToList(); ShowPlanElement element = new ShowPlanElement(ShowPlanOperator.Assert, properties, inputElement); _currentElement = element; return node; }
public override AstNode VisitTableSpoolRefAlgebraNode(StackedTableSpoolRefAlgebraNode node) { PropertyListBuilder propertyListBuilder = new PropertyListBuilder(); AddRowBufferEntries(propertyListBuilder, Resources.ShowPlanGroupOutputList, node.OutputList); AddStatistics(propertyListBuilder, node.StatisticsIterator); propertyListBuilder.Write(Resources.ShowPlanKeyLogicalOperator, Resources.ShowPlanLogicalOperatorLazySpool); propertyListBuilder.Write(Resources.ShowPlanKeyWithStack, Boolean.TrueString); IList <ShowPlanProperty> properties = propertyListBuilder.ToList(); ShowPlanElement element = new ShowPlanElement(ShowPlanOperator.TableSpool, properties); _currentElement = element; return(node); }
public override AlgebraNode VisitComputeScalarAlgebraNode(ComputeScalarAlgebraNode node) { ShowPlanElement inputElement = ConvertNode(node.Input); PropertyListBuilder propertyListBuilder = new PropertyListBuilder(); AddRowBufferEntries(propertyListBuilder, Resources.ShowPlanGroupOutputList, node.OutputList); AddStatistics(propertyListBuilder, node.StatisticsIterator); AddDefinedValues(propertyListBuilder, node.DefinedValues); IList <ShowPlanProperty> properties = propertyListBuilder.ToList(); ShowPlanElement element = new ShowPlanElement(ShowPlanOperator.ComputeScalar, properties, inputElement); _currentElement = element; return(node); }
public override AlgebraNode VisitAggregateAlgebraNode(AggregateAlgebraNode node) { ShowPlanElement inputElement = ConvertNode(node.Input); PropertyListBuilder propertyListBuilder = new PropertyListBuilder(); AddRowBufferEntries(propertyListBuilder, Resources.ShowPlanGroupOutputList, node.OutputList); AddStatistics(propertyListBuilder, node.StatisticsIterator); AddDefinedValues(propertyListBuilder, node.DefinedValues); if (node.Groups != null && node.Groups.Length > 0) AddRowBufferEntries(propertyListBuilder, Resources.ShowPlanGroupGroupBy, node.Groups); IList<ShowPlanProperty> properties = propertyListBuilder.ToList(); ShowPlanElement element = new ShowPlanElement(ShowPlanOperator.StreamAggregate, properties, inputElement); _currentElement = element; return node; }
public override AlgebraNode VisitAssertAlgebraNode(AssertAlgebraNode node) { ShowPlanElement inputElement = ConvertNode(node.Input); PropertyListBuilder propertyListBuilder = new PropertyListBuilder(); AddRowBufferEntries(propertyListBuilder, Resources.ShowPlanGroupOutputList, node.OutputList); AddStatistics(propertyListBuilder, node.StatisticsIterator); propertyListBuilder.Write(Resources.ShowPlanKeyPredicate, node.Predicate.GenerateSource()); IList <ShowPlanProperty> properties = propertyListBuilder.ToList(); ShowPlanElement element = new ShowPlanElement(ShowPlanOperator.Assert, properties, inputElement); _currentElement = element; return(node); }
public override AlgebraNode VisitSortAlgebraNode(SortAlgebraNode node) { ShowPlanElement inputElement = ConvertNode(node.Input); PropertyListBuilder propertyListBuilder = new PropertyListBuilder(); AddRowBufferEntries(propertyListBuilder, Resources.ShowPlanGroupOutputList, node.OutputList); AddStatistics(propertyListBuilder, node.StatisticsIterator); if (node.Distinct) { propertyListBuilder.Write(Resources.ShowPlanKeyLogicalOperator, Resources.ShowPlanLogicalOperatorDistinctSort); } else { propertyListBuilder.Write(Resources.ShowPlanKeyLogicalOperator, Resources.ShowPlanLogicalOperatorSort); } propertyListBuilder.Begin(Resources.ShowPlanGroupOrderBy); for (int i = 0; i < node.SortEntries.Length; i++) { string sortOrder = SortOrderToString(node.SortOrders[i]); propertyListBuilder.Begin(); propertyListBuilder.SetGroupValue(String.Format(CultureInfo.InvariantCulture, "{0} {1}", node.SortEntries[i].Name, sortOrder)); WriteRowBufferEntry(propertyListBuilder, node.SortEntries[i]); propertyListBuilder.Write(Resources.ShowPlanKeyOrder, sortOrder); propertyListBuilder.End(); } propertyListBuilder.End(); IList <ShowPlanProperty> properties = propertyListBuilder.ToList(); ShowPlanElement element = new ShowPlanElement(ShowPlanOperator.Sort, properties, inputElement); _currentElement = element; return(node); }
public override AlgebraNode VisitIndexSpoolAlgebraNode(IndexSpoolAlgebraNode node) { ShowPlanElement inputElement = ConvertNode(node.Input); PropertyListBuilder propertyListBuilder = new PropertyListBuilder(); AddRowBufferEntries(propertyListBuilder, Resources.ShowPlanGroupOutputList, node.OutputList); AddStatistics(propertyListBuilder, node.StatisticsIterator); propertyListBuilder.Write(Resources.ShowPlanKeyLogicalOperator, Resources.ShowPlanLogicalOperatorEagerSpool); propertyListBuilder.Write(Resources.ShowPlanKeyWithStack, Boolean.FalseString); WriteRowBufferEntry(propertyListBuilder, Resources.ShowPlanKeyIndex, node.IndexEntry); propertyListBuilder.Write(Resources.ShowPlanKeyProbe, node.ProbeExpression.GenerateSource()); IList <ShowPlanProperty> properties = propertyListBuilder.ToList(); ShowPlanElement element = new ShowPlanElement(ShowPlanOperator.IndexSpool, properties, inputElement); _currentElement = element; return(node); }
private static void AreEqual(ShowPlanElement expectedPlanElement, ShowPlanElement actualPlanElement) { Assert.AreEqual(expectedPlanElement.Operator, actualPlanElement.Operator); Assert.AreEqual(expectedPlanElement.Properties.Count, actualPlanElement.Properties.Count, "Property count does not match."); for (int i = 0; i < expectedPlanElement.Properties.Count; i++) { ShowPlanProperty expectedProperty = expectedPlanElement.Properties[i]; ShowPlanProperty actualProperty = actualPlanElement.Properties[i]; Assert.AreEqual(expectedProperty.FullName, actualProperty.FullName, "Property full name does not match."); Assert.AreEqual(expectedProperty.Value, actualProperty.Value, "Value of property {0} does not match.", expectedProperty.FullName); } Assert.AreEqual(expectedPlanElement.Children.Count, actualPlanElement.Children.Count, "Count of children does not match."); for (int i = 0; i < expectedPlanElement.Children.Count; i++) { ShowPlanElement expectedChildElement = expectedPlanElement.Children[i]; ShowPlanElement actualChildElement = actualPlanElement.Children[i]; AreEqual(expectedChildElement, actualChildElement); } }
public override AlgebraNode VisitConcatAlgebraNode(ConcatAlgebraNode node) { List <ShowPlanElement> inputList = new List <ShowPlanElement>(); foreach (AlgebraNode inputNode in node.Inputs) { inputList.Add(ConvertNode(inputNode)); } PropertyListBuilder propertyListBuilder = new PropertyListBuilder(); AddRowBufferEntries(propertyListBuilder, Resources.ShowPlanGroupOutputList, node.OutputList); AddStatistics(propertyListBuilder, node.StatisticsIterator); AddDefinedValues(propertyListBuilder, node.DefinedValues); IList <ShowPlanProperty> properties = propertyListBuilder.ToList(); ShowPlanElement element = new ShowPlanElement(ShowPlanOperator.Concatenation, properties, inputList.ToArray()); _currentElement = element; return(node); }
public override AlgebraNode VisitAggregateAlgebraNode(AggregateAlgebraNode node) { ShowPlanElement inputElement = ConvertNode(node.Input); PropertyListBuilder propertyListBuilder = new PropertyListBuilder(); AddRowBufferEntries(propertyListBuilder, Resources.ShowPlanGroupOutputList, node.OutputList); AddStatistics(propertyListBuilder, node.StatisticsIterator); AddDefinedValues(propertyListBuilder, node.DefinedValues); if (node.Groups != null && node.Groups.Length > 0) { AddRowBufferEntries(propertyListBuilder, Resources.ShowPlanGroupGroupBy, node.Groups); } IList <ShowPlanProperty> properties = propertyListBuilder.ToList(); ShowPlanElement element = new ShowPlanElement(ShowPlanOperator.StreamAggregate, properties, inputElement); _currentElement = element; return(node); }
public override AlgebraNode VisitIndexSpoolAlgebraNode(IndexSpoolAlgebraNode node) { ShowPlanElement inputElement = ConvertNode(node.Input); PropertyListBuilder propertyListBuilder = new PropertyListBuilder(); AddRowBufferEntries(propertyListBuilder, Resources.ShowPlanGroupOutputList, node.OutputList); AddStatistics(propertyListBuilder, node.StatisticsIterator); propertyListBuilder.Write(Resources.ShowPlanKeyLogicalOperator, Resources.ShowPlanLogicalOperatorEagerSpool); propertyListBuilder.Write(Resources.ShowPlanKeyWithStack, Boolean.FalseString); WriteRowBufferEntry(propertyListBuilder, Resources.ShowPlanKeyIndex, node.IndexEntry); propertyListBuilder.Write(Resources.ShowPlanKeyProbe, node.ProbeExpression.GenerateSource()); IList<ShowPlanProperty> properties = propertyListBuilder.ToList(); ShowPlanElement element = new ShowPlanElement(ShowPlanOperator.IndexSpool, properties, inputElement); _currentElement = element; return node; }
public override AlgebraNode VisitTableAlgebraNode(TableAlgebraNode node) { PropertyListBuilder propertyListBuilder = new PropertyListBuilder(); propertyListBuilder.Write(Resources.ShowPlanKeyTable, String.Format(CultureInfo.InvariantCulture, "{0} AS {1}", node.TableRefBinding.TableBinding.Name, node.TableRefBinding.Name)); AddRowBufferEntries(propertyListBuilder, Resources.ShowPlanGroupOutputList, node.OutputList); AddStatistics(propertyListBuilder, node.StatisticsIterator); IList<ShowPlanProperty> properties = propertyListBuilder.ToList(); ShowPlanElement element = new ShowPlanElement(ShowPlanOperator.TableScan, properties); _currentElement = element; return node; }
public override AlgebraNode VisitJoinAlgebraNode(JoinAlgebraNode node) { ShowPlanElement leftElement = ConvertNode(node.Left); ShowPlanElement rightElement = ConvertNode(node.Right); PropertyListBuilder propertyListBuilder = new PropertyListBuilder(); AddRowBufferEntries(propertyListBuilder, Resources.ShowPlanGroupOutputList, node.OutputList); propertyListBuilder.Write(Resources.ShowPlanKeyLogicalOperator, LogicalOperatorToString(node.Op)); AddStatistics(propertyListBuilder, node.StatisticsIterator); if (node.Predicate != null) propertyListBuilder.Write(Resources.ShowPlanKeyPredicate, node.Predicate.GenerateSource()); if (node.OuterReferences != null && node.OuterReferences.Length > 0) AddRowBufferEntries(propertyListBuilder, Resources.ShowPlanGroupOuterReferences, node.OuterReferences); if (node.ProbeBufferEntry != null) WriteRowBufferEntry(propertyListBuilder, Resources.ShowPlanKeyProbeColumn, node.ProbeBufferEntry); if (node.PassthruPredicate != null) propertyListBuilder.Write(Resources.ShowPlanKeyPassthru, node.PassthruPredicate.GenerateSource()); // We give a warning if a join has no predicate and no outer reference. // In this case the join would simply multiply the other side. // However, we supppress the warning if any side is known at produce at // most one row. if (node.Predicate == null && (node.OuterReferences == null || node.OuterReferences.Length == 0) && !AstUtil.WillProduceAtMostOneRow(node.Left) && !AstUtil.WillProduceAtMostOneRow(node.Right)) { propertyListBuilder.Write(Resources.ShowPlanKeyWarning, Resources.ShowPlanWarningNoJoinPredicate); } IList<ShowPlanProperty> properties = propertyListBuilder.ToList(); ShowPlanElement element = new ShowPlanElement(ShowPlanOperator.NestedLoops, properties, leftElement, rightElement); _currentElement = element; return node; }
public override AstNode VisitTableSpoolRefAlgebraNode(StackedTableSpoolRefAlgebraNode node) { PropertyListBuilder propertyListBuilder = new PropertyListBuilder(); AddRowBufferEntries(propertyListBuilder, Resources.ShowPlanGroupOutputList, node.OutputList); AddStatistics(propertyListBuilder, node.StatisticsIterator); propertyListBuilder.Write(Resources.ShowPlanKeyLogicalOperator, Resources.ShowPlanLogicalOperatorLazySpool); propertyListBuilder.Write(Resources.ShowPlanKeyWithStack, Boolean.TrueString); IList<ShowPlanProperty> properties = propertyListBuilder.ToList(); ShowPlanElement element = new ShowPlanElement(ShowPlanOperator.TableSpool, properties); _currentElement = element; return node; }
public override AlgebraNode VisitTopAlgebraNode(TopAlgebraNode node) { ShowPlanElement inputElement = ConvertNode(node.Input); PropertyListBuilder propertyListBuilder = new PropertyListBuilder(); AddRowBufferEntries(propertyListBuilder, Resources.ShowPlanGroupOutputList, node.OutputList); AddStatistics(propertyListBuilder, node.StatisticsIterator); propertyListBuilder.Write(Resources.ShowPlanKeyLimit, node.Limit.ToString(CultureInfo.InvariantCulture)); if (node.TieEntries == null) { propertyListBuilder.Write(Resources.ShowPlanKeyWithTies, Boolean.FalseString); } else { propertyListBuilder.Write(Resources.ShowPlanKeyWithTies, Boolean.TrueString); AddRowBufferEntries(propertyListBuilder, Resources.ShowPlanGroupTieColumns, node.TieEntries); } IList<ShowPlanProperty> properties = propertyListBuilder.ToList(); ShowPlanElement element = new ShowPlanElement(ShowPlanOperator.Top, properties, inputElement); _currentElement = element; return node; }
private ShowPlanElement ConvertNode(AlgebraNode node) { Visit(node); ShowPlanElement result = _currentElement; _currentElement = null; return result; }
public override AlgebraNode VisitConcatAlgebraNode(ConcatAlgebraNode node) { List<ShowPlanElement> inputList = new List<ShowPlanElement>(); foreach (AlgebraNode inputNode in node.Inputs) inputList.Add(ConvertNode(inputNode)); PropertyListBuilder propertyListBuilder = new PropertyListBuilder(); AddRowBufferEntries(propertyListBuilder, Resources.ShowPlanGroupOutputList, node.OutputList); AddStatistics(propertyListBuilder, node.StatisticsIterator); AddDefinedValues(propertyListBuilder, node.DefinedValues); IList<ShowPlanProperty> properties = propertyListBuilder.ToList(); ShowPlanElement element = new ShowPlanElement(ShowPlanOperator.Concatenation, properties, inputList.ToArray()); _currentElement = element; return node; }
private static void AddQueryPlanElement(TreeNodeCollection target, ShowPlanElement element) { const string LOGICAL_OPERATOR_KEY = "Logical Operator"; const string TABLE_NAME_KEY = "Table"; const string WITH_TIES_KEY = "With Ties"; const string WARNING_KEY = "Warning"; const int HASH_MATCH_IMG_IDX = 0; const int NESTED_LOOPS_IMG_IDX = 1; const int COMPUTE_SCALAR_IMG_IDX = 2; const int FILTER_IMG_IDX = 3; const int SORT_IMG_IDX = 4; const int STREAM_AGGREGATE_IMG_IDX = 5; const int TOP_IMG_IDX = 6; const int TABLE_SCAN_IMG_IDX = 7; const int SELECT_IMG_IDX = 8; const int CONCATENATION_IMG_IDX = 9; const int CONSTANT_SCAN_IMG_IDX = 10; const int ASSERT_IMG_IDX = 12; const int INDEX_SPOOL_IMG_IDX = 13; const int TABLE_SPOOL_IMG_IDX = 14; int imageIndex; string nodeDetails = null; switch (element.Operator) { case ShowPlanOperator.Select: imageIndex = SELECT_IMG_IDX; break; case ShowPlanOperator.TableScan: imageIndex = TABLE_SCAN_IMG_IDX; nodeDetails = element.Properties[TABLE_NAME_KEY].Value; break; case ShowPlanOperator.NestedLoops: imageIndex = NESTED_LOOPS_IMG_IDX; nodeDetails = element.Properties[LOGICAL_OPERATOR_KEY].Value; break; case ShowPlanOperator.ConstantScan: imageIndex = CONSTANT_SCAN_IMG_IDX; break; case ShowPlanOperator.ComputeScalar: imageIndex = COMPUTE_SCALAR_IMG_IDX; break; case ShowPlanOperator.Concatenation: imageIndex = CONCATENATION_IMG_IDX; break; case ShowPlanOperator.Sort: imageIndex = SORT_IMG_IDX; nodeDetails = element.Properties[LOGICAL_OPERATOR_KEY].Value; break; case ShowPlanOperator.StreamAggregate: imageIndex = STREAM_AGGREGATE_IMG_IDX; break; case ShowPlanOperator.Top: imageIndex = TOP_IMG_IDX; if (element.Properties[WITH_TIES_KEY].Value == Boolean.TrueString) nodeDetails = "With Ties"; break; case ShowPlanOperator.Filter: imageIndex = FILTER_IMG_IDX; break; case ShowPlanOperator.Assert: imageIndex = ASSERT_IMG_IDX; break; case ShowPlanOperator.TableSpool: imageIndex = TABLE_SPOOL_IMG_IDX; nodeDetails = element.Properties[LOGICAL_OPERATOR_KEY].Value; break; case ShowPlanOperator.IndexSpool: imageIndex = INDEX_SPOOL_IMG_IDX; nodeDetails = element.Properties[LOGICAL_OPERATOR_KEY].Value; break; case ShowPlanOperator.HashMatch: imageIndex = HASH_MATCH_IMG_IDX; nodeDetails = element.Properties[LOGICAL_OPERATOR_KEY].Value; break; default: throw ExceptionBuilder.UnhandledCaseLabel(element.Operator); } string nodeName; if (nodeDetails == null) nodeName = element.Operator.ToString(); else nodeName = String.Format(CultureInfo.CurrentCulture, "{0} ({1})", element.Operator, nodeDetails); TreeNode node = new TreeNode(); node.Text = nodeName; node.ImageIndex = node.SelectedImageIndex = imageIndex; node.Tag = element; target.Add(node); if (element.Properties.Contains(WARNING_KEY)) NativeMethods.SetOverlayIndex(node, 1); foreach (ShowPlanElement child in element.Children) AddQueryPlanElement(node.Nodes, child); }
public override AlgebraNode VisitSortAlgebraNode(SortAlgebraNode node) { ShowPlanElement inputElement = ConvertNode(node.Input); PropertyListBuilder propertyListBuilder = new PropertyListBuilder(); AddRowBufferEntries(propertyListBuilder, Resources.ShowPlanGroupOutputList, node.OutputList); AddStatistics(propertyListBuilder, node.StatisticsIterator); if (node.Distinct) propertyListBuilder.Write(Resources.ShowPlanKeyLogicalOperator, Resources.ShowPlanLogicalOperatorDistinctSort); else propertyListBuilder.Write(Resources.ShowPlanKeyLogicalOperator, Resources.ShowPlanLogicalOperatorSort); propertyListBuilder.Begin(Resources.ShowPlanGroupOrderBy); for (int i = 0; i < node.SortEntries.Length; i++) { string sortOrder = SortOrderToString(node.SortOrders[i]); propertyListBuilder.Begin(); propertyListBuilder.SetGroupValue(String.Format(CultureInfo.InvariantCulture, "{0} {1}", node.SortEntries[i].Name, sortOrder)); WriteRowBufferEntry(propertyListBuilder, node.SortEntries[i]); propertyListBuilder.Write(Resources.ShowPlanKeyOrder, sortOrder); propertyListBuilder.End(); } propertyListBuilder.End(); IList<ShowPlanProperty> properties = propertyListBuilder.ToList(); ShowPlanElement element = new ShowPlanElement(ShowPlanOperator.Sort, properties, inputElement); _currentElement = element; return node; }
private static void AddQueryPlanElement(TreeNodeCollection target, ShowPlanElement element) { const string LOGICAL_OPERATOR_KEY = "Logical Operator"; const string TABLE_NAME_KEY = "Table"; const string WITH_TIES_KEY = "With Ties"; const string WARNING_KEY = "Warning"; const int HASH_MATCH_IMG_IDX = 0; const int NESTED_LOOPS_IMG_IDX = 1; const int COMPUTE_SCALAR_IMG_IDX = 2; const int FILTER_IMG_IDX = 3; const int SORT_IMG_IDX = 4; const int STREAM_AGGREGATE_IMG_IDX = 5; const int TOP_IMG_IDX = 6; const int TABLE_SCAN_IMG_IDX = 7; const int SELECT_IMG_IDX = 8; const int CONCATENATION_IMG_IDX = 9; const int CONSTANT_SCAN_IMG_IDX = 10; const int ASSERT_IMG_IDX = 12; const int INDEX_SPOOL_IMG_IDX = 13; const int TABLE_SPOOL_IMG_IDX = 14; int imageIndex; string nodeDetails = null; switch (element.Operator) { case ShowPlanOperator.Select: imageIndex = SELECT_IMG_IDX; break; case ShowPlanOperator.TableScan: imageIndex = TABLE_SCAN_IMG_IDX; nodeDetails = element.Properties[TABLE_NAME_KEY].Value; break; case ShowPlanOperator.NestedLoops: imageIndex = NESTED_LOOPS_IMG_IDX; nodeDetails = element.Properties[LOGICAL_OPERATOR_KEY].Value; break; case ShowPlanOperator.ConstantScan: imageIndex = CONSTANT_SCAN_IMG_IDX; break; case ShowPlanOperator.ComputeScalar: imageIndex = COMPUTE_SCALAR_IMG_IDX; break; case ShowPlanOperator.Concatenation: imageIndex = CONCATENATION_IMG_IDX; break; case ShowPlanOperator.Sort: imageIndex = SORT_IMG_IDX; nodeDetails = element.Properties[LOGICAL_OPERATOR_KEY].Value; break; case ShowPlanOperator.StreamAggregate: imageIndex = STREAM_AGGREGATE_IMG_IDX; break; case ShowPlanOperator.Top: imageIndex = TOP_IMG_IDX; if (element.Properties[WITH_TIES_KEY].Value == Boolean.TrueString) { nodeDetails = "With Ties"; } break; case ShowPlanOperator.Filter: imageIndex = FILTER_IMG_IDX; break; case ShowPlanOperator.Assert: imageIndex = ASSERT_IMG_IDX; break; case ShowPlanOperator.TableSpool: imageIndex = TABLE_SPOOL_IMG_IDX; nodeDetails = element.Properties[LOGICAL_OPERATOR_KEY].Value; break; case ShowPlanOperator.IndexSpool: imageIndex = INDEX_SPOOL_IMG_IDX; nodeDetails = element.Properties[LOGICAL_OPERATOR_KEY].Value; break; case ShowPlanOperator.HashMatch: imageIndex = HASH_MATCH_IMG_IDX; nodeDetails = element.Properties[LOGICAL_OPERATOR_KEY].Value; break; default: throw ExceptionBuilder.UnhandledCaseLabel(element.Operator); } string nodeName; if (nodeDetails == null) { nodeName = element.Operator.ToString(); } else { nodeName = String.Format(CultureInfo.CurrentCulture, "{0} ({1})", element.Operator, nodeDetails); } TreeNode node = new TreeNode(); node.Text = nodeName; node.ImageIndex = node.SelectedImageIndex = imageIndex; node.Tag = element; target.Add(node); if (element.Properties.Contains(WARNING_KEY)) { NativeMethods.SetOverlayIndex(node, 1); } foreach (ShowPlanElement child in element.Children) { AddQueryPlanElement(node.Nodes, child); } }
public override AlgebraNode VisitNullScanAlgebraNode(NullScanAlgebraNode node) { PropertyListBuilder propertyListBuilder = new PropertyListBuilder(); propertyListBuilder.Write(Resources.ShowPlanKeyEmpty, Boolean.TrueString); AddRowBufferEntries(propertyListBuilder, Resources.ShowPlanGroupOutputList, node.OutputList); AddStatistics(propertyListBuilder, node.StatisticsIterator); IList<ShowPlanProperty> properties = propertyListBuilder.ToList(); ShowPlanElement element = new ShowPlanElement(ShowPlanOperator.ConstantScan, properties); _currentElement = element; return node; }
public override AlgebraNode VisitResultAlgebraNode(ResultAlgebraNode node) { ShowPlanElement inputElement = ConvertNode(node.Input); PropertyListBuilder propertyListBuilder = new PropertyListBuilder(); propertyListBuilder.Begin(Resources.ShowPlanGroupOutputList); for (int i = 0; i < node.OutputList.Length; i++) { propertyListBuilder.Begin(); propertyListBuilder.SetGroupValue(String.Format(CultureInfo.InvariantCulture, "{0} AS {1}", node.OutputList[i].Name, node.ColumnNames[i])); WriteRowBufferEntry(propertyListBuilder, node.OutputList[i]); propertyListBuilder.Write(Resources.ShowPlanKeyOutputName, node.ColumnNames[i]); propertyListBuilder.End(); } propertyListBuilder.End(); IList<ShowPlanProperty> properties = propertyListBuilder.ToList(); ShowPlanElement element = new ShowPlanElement(ShowPlanOperator.Select, properties, inputElement); _currentElement = element; return node; }
public override AlgebraNode VisitHashMatchAlgebraNode(HashMatchAlgebraNode node) { ShowPlanElement buildElement = ConvertNode(node.Left); ShowPlanElement probeElement = ConvertNode(node.Right); PropertyListBuilder propertyListBuilder = new PropertyListBuilder(); AddRowBufferEntries(propertyListBuilder, Resources.ShowPlanGroupOutputList, node.OutputList); AddStatistics(propertyListBuilder, node.StatisticsIterator); WriteRowBufferEntry(propertyListBuilder, Resources.ShowPlanKeyHashKeysBuild, node.BuildKeyEntry); WriteRowBufferEntry(propertyListBuilder, Resources.ShowPlanKeyHashKeysProbe, node.ProbeEntry); propertyListBuilder.Write(Resources.ShowPlanKeyLogicalOperator, LogicalOperatorToString(node.Op)); if (node.ProbeResidual != null) propertyListBuilder.Write(Resources.ShowPlanKeyProbeResidual, node.ProbeResidual.GenerateSource()); IList<ShowPlanProperty> properties = propertyListBuilder.ToList(); ShowPlanElement element = new ShowPlanElement(ShowPlanOperator.HashMatch, properties, buildElement, probeElement); _currentElement = element; return node; }