Adding output row and cost info to ep nodes. (#1635)

* Adding more rules for prop

* Adding new output row count and cost info to ep nodes

* Removing commented code
This commit is contained in:
Aasim Khan
2022-08-16 11:36:36 -07:00
committed by GitHub
parent 004a0b2178
commit dd41236ae9
3 changed files with 51 additions and 38 deletions

View File

@@ -46,6 +46,15 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.Contracts
/// </summary>
public double Cost { get; set; }
/// <summary>
/// Output row count associated with the node
/// </summary>
public string RowCountDisplayString { get; set; }
/// <summary>
/// Cost string for the node
/// </summary>
/// <value></value>
public string CostDisplayString { get; set; }
/// <summary>
/// Cost of the node subtree
/// </summary>
public double SubTreeCost { get; set; }

View File

@@ -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<TopOperationsDataItem> 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
});
}

View File

@@ -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