diff --git a/src/Microsoft.SqlTools.ServiceLayer/ExecutionPlan/Contracts/ExecutionPlanGraph.cs b/src/Microsoft.SqlTools.ServiceLayer/ExecutionPlan/Contracts/ExecutionPlanGraph.cs index 7dc94f5f..7744840b 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/ExecutionPlan/Contracts/ExecutionPlanGraph.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/ExecutionPlan/Contracts/ExecutionPlanGraph.cs @@ -46,6 +46,15 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.Contracts /// public double Cost { get; set; } /// + /// Output row count associated with the node + /// + public string RowCountDisplayString { get; set; } + /// + /// Cost string for the node + /// + /// + public string CostDisplayString { get; set; } + /// /// Cost of the node subtree /// public double SubTreeCost { get; set; } diff --git a/src/Microsoft.SqlTools.ServiceLayer/ExecutionPlan/ExecutionPlanGraphUtils.cs b/src/Microsoft.SqlTools.ServiceLayer/ExecutionPlan/ExecutionPlanGraphUtils.cs index eef9d51a..905b4d48 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/ExecutionPlan/ExecutionPlanGraphUtils.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/ExecutionPlan/ExecutionPlanGraphUtils.cs @@ -40,6 +40,8 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan ID = currentNode.ID, Type = currentNode.Operation.Image, Cost = currentNode.Cost, + RowCountDisplayString = currentNode.GetRowCountDisplayString(), + CostDisplayString = currentNode.GetNodeCostDisplayString(), SubTreeCost = currentNode.SubtreeCost, Description = currentNode.Description, Subtext = currentNode.GetDisplayLinesOfText(true), @@ -106,7 +108,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan var complexProperty = prop.Value as ExpandableObjectWrapper; if (complexProperty == null) { - if(!prop.IsBrowsable) + if (!prop.IsBrowsable) { continue; } @@ -165,7 +167,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan } public static List ParseTopOperationsData(Node currentNode) - { + { const string OBJECT_COLUMN_KEY = "Object"; const string ESTIMATED_ROWS_COLUMN_KEY = "EstimateRows"; const string ACTUAL_ROWS_COLUMN_KEY = "ActualRows"; @@ -197,7 +199,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan { ColumnName = SR.Object, DataType = PropertyValueDataType.String, - DisplayValue = ((ExpandableObjectWrapper)currentNode[OBJECT_COLUMN_KEY]).DisplayName + DisplayValue = ((ExpandableObjectWrapper)currentNode[OBJECT_COLUMN_KEY]).DisplayName }); } diff --git a/src/Microsoft.SqlTools.ServiceLayer/ExecutionPlan/ShowPlan/Node.cs b/src/Microsoft.SqlTools.ServiceLayer/ExecutionPlan/ShowPlan/Node.cs index 25163cf4..42ea2667 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/ExecutionPlan/ShowPlan/Node.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/ExecutionPlan/ShowPlan/Node.cs @@ -85,13 +85,6 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan firstLine = this.Operation.DisplayName; } - // Check if the PhysicalOp is specialized to a specific kind - string firstLineAppend = this["PhysicalOperationKind"] as string; - if (firstLineAppend != null) - { - firstLine = String.Format(CultureInfo.CurrentCulture, "{0} {1}", firstLine, Constants.Parenthesis(firstLineAppend)); - } - string secondLine; @@ -585,34 +578,6 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan { string newDisplayNameLines = this.DisplayName; - // cost - double cost = this.RelativeCost * 100; - - if (!this.HasPDWCost || cost > 0) - { - if (roundCostForSmallGraph && this.graph != null && this.graph.NodeStmtMap.Count < Node.LargePlanNodeCount) - { - cost = Math.Round(cost); - } - string costText = SR.CostFormat(cost.ToString("0.##")); - newDisplayNameLines += '\n' + costText; - } - - - // elapsed time in miliseconds - string elapsedTime = GetElapsedTimeDisplayString(); - if (!String.IsNullOrEmpty(elapsedTime)) - { - newDisplayNameLines += '\n' + elapsedTime; - } - - // actual/estimated rows - string rowStatistics = GetRowStatisticsDisplayString(); - if (!String.IsNullOrEmpty(rowStatistics)) - { - newDisplayNameLines += '\n' + rowStatistics; - } - return newDisplayNameLines.Split('\n'); } @@ -704,6 +669,43 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan return SR.ActualOfEstimated(actualString, estimateString, percent); } + public string GetRowCountDisplayString() + { + var actualRowsCounters = this[NodeBuilderConstants.ActualRows] as RunTimeCounters; + ulong? actualRows = actualRowsCounters != null ? actualRowsCounters.TotalCounters : (ulong?)null; + if (actualRows != null) + { + return actualRows.Value.ToString(); + } + var estimateRows = this[NodeBuilderConstants.EstimateRows] as double?; + var estimateExecutions = this[NodeBuilderConstants.EstimateExecutions] as double?; + + if (estimateRows != null) + { + if (estimateExecutions != null) + { + estimateRows = estimateRows * estimateExecutions; + } + // we display estimate rows as integer so need round function + estimateRows = Math.Round(estimateRows.Value); + } + return estimateRows == null ? "" : estimateRows.Value.ToString(); + } + + public string GetNodeCostDisplayString() + { + double cost = this.RelativeCost * 100; + string costText = ""; + if (!this.HasPDWCost || cost > 0) + { + if (this.graph != null && this.graph.NodeStmtMap.Count < Node.LargePlanNodeCount) + { + cost = Math.Round(cost); + } + costText = cost.ToString("0.##") + "%"; + } + return costText; + } #endregion