aboutsummaryrefslogtreecommitdiff
path: root/app/services
diff options
context:
space:
mode:
Diffstat (limited to 'app/services')
-rw-r--r--app/services/help-service.ts5
-rw-r--r--app/services/plan-service.ts29
2 files changed, 29 insertions, 5 deletions
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 <strong>Bitmap Index Scan</strong> for relevant rows.',
'BITMAP INDEX SCAN': `uses a <strong>Bitmap Index</strong> (index which uses 1 bit per page) to find all relevant pages.
- Results of this node are fed to the <strong>Bitmap Heap Scan</strong>.`
+ Results of this node are fed to the <strong>Bitmap Heap Scan</strong>.`,
+ 'CTE SCAN': `performs a sequential scan of <strong>Common Table Expression (CTE) query</strong> 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 b5f8102..0e399ff 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_';
@@ -49,11 +52,14 @@ 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]));
}
}
- return plans;
+ return _.chain(plans)
+ .sortBy('createdOn')
+ .reverse()
+ .value();
}
getPlan(id: string): IPlan {
@@ -73,6 +79,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;
@@ -150,9 +165,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) {