From d256691ac0e4d2e1cd41ef1c1d9ce3c310e77dc6 Mon Sep 17 00:00:00 2001 From: Alex Tatiyants Date: Fri, 29 Jan 2016 21:05:29 -0800 Subject: fix #12 --- app/services/plan-service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/services') diff --git a/app/services/plan-service.ts b/app/services/plan-service.ts index b5f8102..a32001b 100644 --- a/app/services/plan-service.ts +++ b/app/services/plan-service.ts @@ -49,7 +49,7 @@ export class PlanService { for (var i in localStorage) { if (_.startsWith(i, this.PEV_PLAN_TAG)) { - plans.push(JSON.parse(localStorage[i])); + plans.push(JSON.parse(localStorage[i])); } } -- cgit v1.2.3 From 781479ea7f793c8d075caee53f6413a1d2e85307 Mon Sep 17 00:00:00 2001 From: Alex Tatiyants Date: Fri, 29 Jan 2016 21:33:19 -0800 Subject: add plan validation --- app/services/plan-service.ts | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'app/services') diff --git a/app/services/plan-service.ts b/app/services/plan-service.ts index a32001b..e634f64 100644 --- a/app/services/plan-service.ts +++ b/app/services/plan-service.ts @@ -73,6 +73,15 @@ export class PlanService { return plan; } + isJsonString(str) { + try { + JSON.parse(str); + } catch (e) { + return false; + } + return true; + } + analyzePlan(plan: IPlan) { this.processNode(plan.content.Plan); plan.content[this.MAXIMUM_ROWS_PROP] = this._maxRows; -- cgit v1.2.3 From cd2af1466b1c23f81c13af61fa550475f82e0227 Mon Sep 17 00:00:00 2001 From: Alex Tatiyants Date: Sat, 5 Mar 2016 11:58:52 -0800 Subject: better handle CTE scans, including correct duration calculations. fix #15 --- app/services/help-service.ts | 5 ++++- app/services/plan-service.ts | 13 +++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) (limited to 'app/services') diff --git a/app/services/help-service.ts b/app/services/help-service.ts index 6067b05..532d694 100644 --- a/app/services/help-service.ts +++ b/app/services/help-service.ts @@ -26,5 +26,8 @@ export var NODE_DESCRIPTIONS = { from the index and do not read from the corresponding table.`, 'BITMAP HEAP SCAN': 'searches through the pages returned by the Bitmap Index Scan for relevant rows.', 'BITMAP INDEX SCAN': `uses a Bitmap Index (index which uses 1 bit per page) to find all relevant pages. - Results of this node are fed to the Bitmap Heap Scan.` + Results of this node are fed to the Bitmap Heap Scan.`, + 'CTE SCAN': `performs a sequential scan of Common Table Expression (CTE) query results. Note that + results of a CTE are materialized (calculated and temporarily stored).` + }; 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) { -- cgit v1.2.3 From eae3aee1bbfb29dd31e92853664a373e3d60d6b6 Mon Sep 17 00:00:00 2001 From: Alex Tatiyants Date: Sat, 16 Apr 2016 12:54:48 -0700 Subject: sort plans in reverse chronological order --- app/services/plan-service.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'app/services') diff --git a/app/services/plan-service.ts b/app/services/plan-service.ts index c34a52a..0e399ff 100644 --- a/app/services/plan-service.ts +++ b/app/services/plan-service.ts @@ -56,7 +56,10 @@ export class PlanService { } } - return plans; + return _.chain(plans) + .sortBy('createdOn') + .reverse() + .value(); } getPlan(id: string): IPlan { -- cgit v1.2.3