aboutsummaryrefslogtreecommitdiff
path: root/app/services/plan-service.ts
diff options
context:
space:
mode:
authorAlex Tatiyants <atatiyan@gmail.com>2016-03-05 11:58:52 -0800
committerAlex Tatiyants <atatiyan@gmail.com>2016-03-05 11:58:52 -0800
commitcd2af1466b1c23f81c13af61fa550475f82e0227 (patch)
tree30c17082928a60c4822b0499ac4ca9b5e1731b3a /app/services/plan-service.ts
parent7fc812bc761c95e508e1c540393b12b03cdf1d03 (diff)
better handle CTE scans, including correct duration calculations. fix #15
Diffstat (limited to 'app/services/plan-service.ts')
-rw-r--r--app/services/plan-service.ts13
1 files changed, 11 insertions, 2 deletions
diff --git a/app/services/plan-service.ts b/app/services/plan-service.ts
index e634f64..c34a52a 100644
--- a/app/services/plan-service.ts
+++ b/app/services/plan-service.ts
@@ -36,6 +36,9 @@ export class PlanService {
PLANNER_ESTIMATE_FACTOR: string = '*Planner Row Estimate Factor';
PLANNER_ESIMATE_DIRECTION: string = '*Planner Row Estimate Direction';
+ CTE_SCAN_PROP = 'CTE Scan';
+ CTE_NAME_PROP = 'CTE Name';
+
ARRAY_INDEX_KEY: string = 'arrayIndex';
PEV_PLAN_TAG: string = 'plan_';
@@ -159,9 +162,15 @@ export class PlanService {
node[this.ACTUAL_DURATION_PROP] = node[this.ACTUAL_TOTAL_TIME_PROP];
node[this.ACTUAL_COST_PROP] = node[this.TOTAL_COST_PROP];
+ console.log (node);
_.each(node.Plans, subPlan => {
- node[this.ACTUAL_DURATION_PROP] = node[this.ACTUAL_DURATION_PROP] - subPlan[this.ACTUAL_TOTAL_TIME_PROP];
- node[this.ACTUAL_COST_PROP] = node[this.ACTUAL_COST_PROP] - subPlan[this.TOTAL_COST_PROP];
+ console.log('processing chldren', subPlan)
+ // since CTE scan duration is already included in its subnodes, it should be be
+ // subtracted from the duration of this node
+ if (subPlan[this.NODE_TYPE_PROP] !== this.CTE_SCAN_PROP) {
+ node[this.ACTUAL_DURATION_PROP] = node[this.ACTUAL_DURATION_PROP] - subPlan[this.ACTUAL_TOTAL_TIME_PROP];
+ node[this.ACTUAL_COST_PROP] = node[this.ACTUAL_COST_PROP] - subPlan[this.TOTAL_COST_PROP];
+ }
});
if (node[this.ACTUAL_COST_PROP] < 0) {