agora inbox for [email protected]  
help / color / mirror / Atom feed
From: Justin Pryzby <[email protected]>
Subject: [PATCH v1] explain: show index_total_cost
Date: Fri, 3 Jan 2020 09:53:31 -0600

---
 src/backend/commands/explain.c          | 3 +++
 src/backend/optimizer/plan/createplan.c | 1 +
 src/include/nodes/plannodes.h           | 1 +
 3 files changed, 5 insertions(+)

diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c
index 0910d91..8973c86 100644
--- a/src/backend/commands/explain.c
+++ b/src/backend/commands/explain.c
@@ -1614,6 +1614,9 @@ ExplainNode(PlanState *planstate, List *ancestors,
 			if (plan->qual)
 				show_instrumentation_count("Rows Removed by Filter", 1,
 										   planstate, es);
+			if (es->costs && es->verbose) // && verbose ?
+				ExplainPropertyFloat("Index Total Cost", NULL,
+									   planstate->plan->indextotalcost, 2, es);
 			break;
 		case T_IndexOnlyScan:
 			show_scan_qual(((IndexOnlyScan *) plan)->indexqual,
diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c
index dff826a..c0419bc 100644
--- a/src/backend/optimizer/plan/createplan.c
+++ b/src/backend/optimizer/plan/createplan.c
@@ -2924,6 +2924,7 @@ create_indexscan_plan(PlannerInfo *root,
 											best_path->indexscandir);
 
 	copy_generic_path_info(&scan_plan->plan, &best_path->path);
+	((Plan *)scan_plan)->indextotalcost = best_path->indextotalcost;
 
 	return scan_plan;
 }
diff --git a/src/include/nodes/plannodes.h b/src/include/nodes/plannodes.h
index 32c0d87..711c9d8 100644
--- a/src/include/nodes/plannodes.h
+++ b/src/include/nodes/plannodes.h
@@ -122,6 +122,7 @@ typedef struct Plan
 	 */
 	Cost		startup_cost;	/* cost expended before fetching any tuples */
 	Cost		total_cost;		/* total cost (assuming all tuples fetched) */
+	Cost		indextotalcost;		/* total cost of index */
 
 	/*
 	 * planner's estimate of result size of this plan step
-- 
2.7.4


--PNTmBPCT7hxwcZjr--





view thread (2+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected]
  Subject: Re: [PATCH v1] explain: show index_total_cost
  In-Reply-To: <no-message-id-191880@localhost>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox