mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-17 02:51:45 -05:00
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:
@@ -46,6 +46,15 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.Contracts
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public double Cost { get; set; }
|
public double Cost { get; set; }
|
||||||
/// <summary>
|
/// <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
|
/// Cost of the node subtree
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double SubTreeCost { get; set; }
|
public double SubTreeCost { get; set; }
|
||||||
|
|||||||
@@ -40,6 +40,8 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan
|
|||||||
ID = currentNode.ID,
|
ID = currentNode.ID,
|
||||||
Type = currentNode.Operation.Image,
|
Type = currentNode.Operation.Image,
|
||||||
Cost = currentNode.Cost,
|
Cost = currentNode.Cost,
|
||||||
|
RowCountDisplayString = currentNode.GetRowCountDisplayString(),
|
||||||
|
CostDisplayString = currentNode.GetNodeCostDisplayString(),
|
||||||
SubTreeCost = currentNode.SubtreeCost,
|
SubTreeCost = currentNode.SubtreeCost,
|
||||||
Description = currentNode.Description,
|
Description = currentNode.Description,
|
||||||
Subtext = currentNode.GetDisplayLinesOfText(true),
|
Subtext = currentNode.GetDisplayLinesOfText(true),
|
||||||
@@ -106,7 +108,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan
|
|||||||
var complexProperty = prop.Value as ExpandableObjectWrapper;
|
var complexProperty = prop.Value as ExpandableObjectWrapper;
|
||||||
if (complexProperty == null)
|
if (complexProperty == null)
|
||||||
{
|
{
|
||||||
if(!prop.IsBrowsable)
|
if (!prop.IsBrowsable)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -165,7 +167,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static List<TopOperationsDataItem> ParseTopOperationsData(Node currentNode)
|
public static List<TopOperationsDataItem> ParseTopOperationsData(Node currentNode)
|
||||||
{
|
{
|
||||||
const string OBJECT_COLUMN_KEY = "Object";
|
const string OBJECT_COLUMN_KEY = "Object";
|
||||||
const string ESTIMATED_ROWS_COLUMN_KEY = "EstimateRows";
|
const string ESTIMATED_ROWS_COLUMN_KEY = "EstimateRows";
|
||||||
const string ACTUAL_ROWS_COLUMN_KEY = "ActualRows";
|
const string ACTUAL_ROWS_COLUMN_KEY = "ActualRows";
|
||||||
@@ -197,7 +199,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan
|
|||||||
{
|
{
|
||||||
ColumnName = SR.Object,
|
ColumnName = SR.Object,
|
||||||
DataType = PropertyValueDataType.String,
|
DataType = PropertyValueDataType.String,
|
||||||
DisplayValue = ((ExpandableObjectWrapper)currentNode[OBJECT_COLUMN_KEY]).DisplayName
|
DisplayValue = ((ExpandableObjectWrapper)currentNode[OBJECT_COLUMN_KEY]).DisplayName
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -85,13 +85,6 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
|
|||||||
firstLine = this.Operation.DisplayName;
|
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;
|
string secondLine;
|
||||||
|
|
||||||
@@ -585,34 +578,6 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
|
|||||||
{
|
{
|
||||||
string newDisplayNameLines = this.DisplayName;
|
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');
|
return newDisplayNameLines.Split('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -704,6 +669,43 @@ namespace Microsoft.SqlTools.ServiceLayer.ExecutionPlan.ShowPlan
|
|||||||
return SR.ActualOfEstimated(actualString, estimateString, percent);
|
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
|
#endregion
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user