diff --git a/src/Microsoft.SqlTools.ServiceLayer/ExecutionPlan/Contracts/ExecutionPlanGraph.cs b/src/Microsoft.SqlTools.ServiceLayer/ExecutionPlan/Contracts/ExecutionPlanGraph.cs index dab76ca8..7dc94f5f 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/ExecutionPlan/Contracts/ExecutionPlanGraph.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/ExecutionPlan/Contracts/ExecutionPlanGraph.cs @@ -79,6 +79,10 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.Contracts /// Add badge icon to nodes like warnings and parallelism /// public List Badges { get; set; } + /// + /// Top operations table data for the node + /// + public List TopOperationsData { get; set; } } public class ExecutionPlanGraphPropertyBase @@ -206,4 +210,11 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.Contracts Boolean = 2, Nested = 3 } + + public class TopOperationsDataItem + { + public string ColumnName { get; set; } + public PropertyValueDataType DataType { get; set; } + public object DisplayValue { get; set; } + } } \ No newline at end of file diff --git a/src/Microsoft.SqlTools.ServiceLayer/ExecutionPlan/ExecutionPlanGraphUtils.cs b/src/Microsoft.SqlTools.ServiceLayer/ExecutionPlan/ExecutionPlanGraphUtils.cs index d9c16867..e49760b8 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/ExecutionPlan/ExecutionPlanGraphUtils.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/ExecutionPlan/ExecutionPlanGraphUtils.cs @@ -34,7 +34,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan } public static ExecutionPlanNode ConvertShowPlanTreeToExecutionPlanTree(Node currentNode) - { + { return new ExecutionPlanNode { ID = currentNode.ID, @@ -49,7 +49,8 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan Edges = currentNode.Edges.Select(x => ConvertShowPlanEdgeToExecutionPlanEdge(x)).ToList(), Badges = GenerateNodeOverlay(currentNode), Name = currentNode.DisplayName, - ElapsedTimeInMs = currentNode.ElapsedTimeInMs + ElapsedTimeInMs = currentNode.ElapsedTimeInMs, + TopOperationsData = ParseTopOperationsData(currentNode) }; } @@ -163,6 +164,173 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan return propsList; } + public static List ParseTopOperationsData(Node currentNode) + { + List result = new List(); + result.Add(new TopOperationsDataItem + { + ColumnName = SR.Operation, + DataType = PropertyValueDataType.String, + DisplayValue = currentNode.Operation.DisplayName + }); + + if (currentNode["Object"] != null) + { + result.Add(new TopOperationsDataItem + { + ColumnName = SR.Object, + DataType = PropertyValueDataType.String, + DisplayValue = ((ExpandableObjectWrapper)currentNode["Object"]).DisplayName + }); + } + + result.Add(new TopOperationsDataItem + { + ColumnName = SR.EstimatedCost, + DataType = PropertyValueDataType.Number, + DisplayValue = Math.Round(currentNode.Cost, 1) + }); + + result.Add(new TopOperationsDataItem + { + ColumnName = SR.EstimatedSubtree, + DataType = PropertyValueDataType.Number, + DisplayValue = Math.Round(currentNode.SubtreeCost, 1) + }); + + if (currentNode["ActualRows"] != null) + { + result.Add(new TopOperationsDataItem + { + ColumnName = SR.ActualRows, + DataType = PropertyValueDataType.Number, + DisplayValue = currentNode["ActualRows"] + }); + } + + if (currentNode["AvgRowSize"] != null) + { + result.Add(new TopOperationsDataItem + { + ColumnName = SR.EstimatedAverageRowSize, + DataType = PropertyValueDataType.Number, + DisplayValue = currentNode["AvgRowSize"] + }); + } + + if (currentNode["ActualExecutions"] != null) + { + result.Add(new TopOperationsDataItem + { + ColumnName = SR.ActualExecutions, + DataType = PropertyValueDataType.Number, + DisplayValue = currentNode["ActualExecutions"] + }); + } + + if (currentNode["EstimateExecutions"] != null) + { + result.Add(new TopOperationsDataItem + { + ColumnName = SR.EstimatedExecutions, + DataType = PropertyValueDataType.Number, + DisplayValue = currentNode["EstimateExecutions"] + }); + } + + if (currentNode["EstimateCPU"] != null) + { + result.Add(new TopOperationsDataItem + { + ColumnName = SR.EstimatedCpu, + DataType = PropertyValueDataType.Number, + DisplayValue = currentNode["EstimateCPU"] + }); + } + + if (currentNode["EstimateIO"] != null) + { + result.Add(new TopOperationsDataItem + { + ColumnName = SR.EstimatedIO, + DataType = PropertyValueDataType.Number, + DisplayValue = currentNode["EstimateIO"] + }); + } + + if (currentNode["Parallel"] != null) + { + result.Add(new TopOperationsDataItem + { + ColumnName = SR.Parallel, + DataType = PropertyValueDataType.Boolean, + DisplayValue = currentNode["Parallel"] + }); + } + + if (currentNode["Ordered"] != null) + { + result.Add(new TopOperationsDataItem + { + ColumnName = SR.Ordered, + DataType = PropertyValueDataType.Boolean, + DisplayValue = currentNode["Ordered"] + }); + } + + if (currentNode["ActualRewinds"] != null) + { + result.Add(new TopOperationsDataItem + { + ColumnName = SR.ActualRewinds, + DataType = PropertyValueDataType.Number, + DisplayValue = currentNode["ActualRewinds"] + }); + } + + if (currentNode["EstimateRewinds"] != null) + { + result.Add(new TopOperationsDataItem + { + ColumnName = SR.EstimatedRewinds, + DataType = PropertyValueDataType.Number, + DisplayValue = currentNode["EstimateRewinds"] + }); + } + + if (currentNode["ActualRebinds"] != null) + { + result.Add(new TopOperationsDataItem + { + ColumnName = SR.ActualRebinds, + DataType = PropertyValueDataType.Number, + DisplayValue = currentNode["ActualRebinds"] + }); + } + + + if (currentNode["EstimateRebinds"] != null) + { + result.Add(new TopOperationsDataItem + { + ColumnName = SR.EstimatedRebinds, + DataType = PropertyValueDataType.Number, + DisplayValue = currentNode["EstimateRebinds"] + }); + } + + if (currentNode["Partitioned"] != null) + { + result.Add(new TopOperationsDataItem + { + ColumnName = SR.Partitioned, + DataType = PropertyValueDataType.Boolean, + DisplayValue = currentNode["Partitioned"] + }); + } + return result; + } + private static List ParseRecommendations(ShowPlanGraph g, string fileName) { return g.Description.MissingIndices.Select(mi => new ExecutionPlanRecommendation diff --git a/src/Microsoft.SqlTools.ServiceLayer/ExecutionPlan/ShowPlan/Node.cs b/src/Microsoft.SqlTools.ServiceLayer/ExecutionPlan/ShowPlan/Node.cs index 7247a882..663aa511 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/ExecutionPlan/ShowPlan/Node.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/ExecutionPlan/ShowPlan/Node.cs @@ -576,11 +576,6 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan return true; } - /// - /// Gets lines of text displayed under the icon. - /// - /// Array of strings. - /// /// Gets lines of text displayed under the icon. /// @@ -595,7 +590,8 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan if (!this.HasPDWCost || cost > 0) { - if(roundCostForSmallGraph && this.graph != null && this.graph.NodeStmtMap.Count < 20){ + if (roundCostForSmallGraph && this.graph != null && this.graph.NodeStmtMap.Count < 20) + { cost = Math.Round(cost); } string costText = SR.CostFormat(cost.ToString("0.##")); diff --git a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.cs b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.cs index f91e8cd3..a1c6b4f6 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.cs @@ -8485,6 +8485,102 @@ namespace Microsoft.SqlTools.ServiceLayer } } + public static string Operation + { + get + { + return Keys.GetString(Keys.Operation); + } + } + + public static string Object + { + get + { + return Keys.GetString(Keys.Object); + } + } + + public static string EstimatedCost + { + get + { + return Keys.GetString(Keys.EstimatedCost); + } + } + + public static string EstimatedSubtree + { + get + { + return Keys.GetString(Keys.EstimatedSubtree); + } + } + + public static string ActualRows + { + get + { + return Keys.GetString(Keys.ActualRows); + } + } + + public static string EstimatedRows + { + get + { + return Keys.GetString(Keys.EstimatedRows); + } + } + + public static string ActualExecutions + { + get + { + return Keys.GetString(Keys.ActualExecutions); + } + } + + public static string EstimatedExecutions + { + get + { + return Keys.GetString(Keys.EstimatedExecutions); + } + } + + public static string EstimatedCpu + { + get + { + return Keys.GetString(Keys.EstimatedCpu); + } + } + + public static string EstimatedIO + { + get + { + return Keys.GetString(Keys.EstimatedIO); + } + } + + public static string EstimatedAverageRowSize + { + get + { + return Keys.GetString(Keys.EstimatedAverageRowSize); + } + } + + public static string ActualDataSize + { + get + { + return Keys.GetString(Keys.ActualDataSize); + } + } + public static string TableEditPathNotProvidedException { get @@ -12950,6 +13046,42 @@ namespace Microsoft.SqlTools.ServiceLayer public const string ParallelismOverlayTooltip = "ParallelismOverlayTooltip"; + public const string Operation = "Operation"; + + + public const string Object = "Object"; + + + public const string EstimatedCost = "EstimatedCost"; + + + public const string EstimatedSubtree = "EstimatedSubtree"; + + + public const string ActualRows = "ActualRows"; + + + public const string EstimatedRows = "EstimatedRows"; + + + public const string ActualExecutions = "ActualExecutions"; + + + public const string EstimatedExecutions = "EstimatedExecutions"; + + + public const string EstimatedCpu = "EstimatedCpu"; + + + public const string EstimatedIO = "EstimatedIO"; + + + public const string EstimatedAverageRowSize = "EstimatedAverageRowSize"; + + + public const string ActualDataSize = "ActualDataSize"; + + public const string TableNotInitializedException = "TableNotInitializedException"; diff --git a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.resx b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.resx index 0a9f07ce..7be96b4f 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.resx +++ b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.resx @@ -4644,6 +4644,54 @@ The Query Processor estimates that implementing the following index could improv Parallel Execution tooltip text for node parallelism overlay + + Operation + + + + Object + + + + Estimated Cost % + + + + Estimated Subtree Cost % + + + + Actual Rows + + + + Estimated Rows + + + + Actual Executions + + + + Estimated Executions + + + + Estimated CPU Cost + + + + Estimated IO Cost + + + + Estimated Average Row Size + + + + Actual Data Size + + Initialization is not properly done for table with id '{0}' . diff --git a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.strings b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.strings index f25d24bb..5b91fb02 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.strings +++ b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.strings @@ -2234,6 +2234,22 @@ WarningOverlayTooltip = Warnings ;tooltip text for node parallelism overlay ParallelismOverlayTooltip = Parallel Execution +# +# Top operation column Names +# +Operation = Operation +Object = Object +EstimatedCost = Estimated Cost % +EstimatedSubtree = Estimated Subtree Cost % +ActualRows = Actual Rows +EstimatedRows = Estimated Rows +ActualExecutions = Actual Executions +EstimatedExecutions = Estimated Executions +EstimatedCpu = Estimated CPU Cost +EstimatedIO = Estimated IO Cost +EstimatedAverageRowSize = Estimated Average Row Size +ActualDataSize = Actual Data Size + ############################################################################ # Table Designer diff --git a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.xlf b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.xlf index 059f46ea..cf942381 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.xlf +++ b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.xlf @@ -6194,6 +6194,66 @@ The Query Processor estimates that implementing the following index could improv There are multiple table definitions in the script, only the first table can be edited in the designer. + + Operation + Operation + + + + Object + Object + + + + Estimated Cost % + Estimated Cost % + + + + Estimated Subtree Cost % + Estimated Subtree Cost % + + + + Actual Rows + Actual Rows + + + + Estimated Rows + Estimated Rows + + + + Actual Executions + Actual Executions + + + + Estimated Executions + Estimated Executions + + + + Estimated CPU Cost + Estimated CPU Cost + + + + Estimated IO Cost + Estimated IO Cost + + + + Actual Data Size + Actual Data Size + + + + Estimated Average Row Size + Estimated Average Row Size + + \ No newline at end of file