diff --git a/doc/src/sgml/ref/explain.sgml b/doc/src/sgml/ref/explain.sgml
index 4d83359..c63728d 100644
--- a/doc/src/sgml/ref/explain.sgml
+++ b/doc/src/sgml/ref/explain.sgml
@@ -202,7 +202,10 @@ ROLLBACK;
     <listitem>
      <para>
       Include planning time and execution time. Execution time is included
-      when <literal>ANALYZE</literal> is enabled.
+      when <literal>ANALYZE</literal> is enabled. Planning time in
+      <command>EXPLAIN EXECUTE</command> includes the time required to fetch
+      the plan from the cache and the time required for re-planning, if
+      necessary.
       It defaults to <literal>TRUE</literal> when <literal>ANALYZE</literal>
       is enabled. Otherwise it defaults to <literal>FALSE</literal>.
      </para>
diff --git a/src/backend/commands/prepare.c b/src/backend/commands/prepare.c
index b01051d..ddce8a4 100644
--- a/src/backend/commands/prepare.c
+++ b/src/backend/commands/prepare.c
@@ -629,10 +629,19 @@ ExplainExecuteQuery(ExecuteStmt *execstmt, IntoClause *into, ExplainState *es,
 	ListCell   *p;
 	ParamListInfo paramLI = NULL;
 	EState	   *estate = NULL;
+	instr_time	start;
+	instr_time	end;
+	instr_time	duration;
+
+	INSTR_TIME_SET_ZERO(duration);
+	INSTR_TIME_SET_CURRENT(start);
 
 	/* Look it up in the hash table */
 	entry = FetchPreparedStatement(execstmt->name, true);
 
+	INSTR_TIME_SET_CURRENT(end);
+	INSTR_TIME_ACCUM_DIFF(duration, end, start);
+
 	/* Shouldn't find a non-fixed-result cached plan */
 	if (!entry->plansource->fixed_result)
 		elog(ERROR, "EXPLAIN EXECUTE does not support variable-result cached plans");
@@ -654,9 +663,14 @@ ExplainExecuteQuery(ExecuteStmt *execstmt, IntoClause *into, ExplainState *es,
 								 queryString, estate);
 	}
 
+	INSTR_TIME_SET_CURRENT(start);
+
 	/* Replan if needed, and acquire a transient refcount */
 	cplan = GetCachedPlan(entry->plansource, paramLI, true);
 
+	INSTR_TIME_SET_CURRENT(end);
+	INSTR_TIME_ACCUM_DIFF(duration, end, start);
+
 	plan_list = cplan->stmt_list;
 
 	/* Explain each query */
@@ -665,7 +679,7 @@ ExplainExecuteQuery(ExecuteStmt *execstmt, IntoClause *into, ExplainState *es,
 		PlannedStmt *pstmt = (PlannedStmt *) lfirst(p);
 
 		if (IsA(pstmt, PlannedStmt))
-			ExplainOnePlan(pstmt, into, es, query_string, paramLI, NULL);
+			ExplainOnePlan(pstmt, into, es, query_string, paramLI, &duration);
 		else
 			ExplainOneUtility((Node *) pstmt, into, es, query_string, paramLI);
 
