77 * Portions Copyright (c) 1994-5, Regents of the University of California
88 *
99 * IDENTIFICATION
10- * $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.136 2005/06/03 23:05:28 tgl Exp $
10+ * $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.137 2005/06/04 02:07:09 neilc Exp $
1111 *
1212 *-------------------------------------------------------------------------
1313 */
3838typedef struct ExplainState
3939{
4040/* options */
41- bool printCost ;/* print cost */
4241bool printNodes ;/* do nodeToString() too */
4342bool printAnalyze ;/* print actual times */
4443/* other states */
@@ -246,7 +245,6 @@ ExplainOnePlan(QueryDesc *queryDesc, ExplainStmt *stmt,
246245
247246es = (ExplainState * )palloc0 (sizeof (ExplainState ));
248247
249- es -> printCost = true;/* default */
250248es -> printNodes = stmt -> verbose ;
251249es -> printAnalyze = stmt -> analyze ;
252250es -> rtable = queryDesc -> parsetree -> rtable ;
@@ -266,18 +264,14 @@ ExplainOnePlan(QueryDesc *queryDesc, ExplainStmt *stmt,
266264pfree (s );
267265do_text_output_multiline (tstate ,f );
268266pfree (f );
269- if (es -> printCost )
270- do_text_output_oneline (tstate ,"" );/* separator line */
267+ do_text_output_oneline (tstate ,"" );/* separator line */
271268}
272269}
273270
274271str = makeStringInfo ();
275272
276- if (es -> printCost )
277- {
278- explain_outNode (str ,queryDesc -> plantree ,queryDesc -> planstate ,
279- NULL ,0 ,es );
280- }
273+ explain_outNode (str ,queryDesc -> plantree ,queryDesc -> planstate ,
274+ NULL ,0 ,es );
281275
282276/*
283277 * If we ran the command, run any AFTER triggers it queued. (Note this
@@ -358,13 +352,10 @@ ExplainOnePlan(QueryDesc *queryDesc, ExplainStmt *stmt,
358352
359353totaltime += elapsed_time (& starttime );
360354
361- if (es -> printCost )
362- {
363- if (stmt -> analyze )
364- appendStringInfo (str ,"Total runtime: %.3f ms\n" ,
365- 1000.0 * totaltime );
366- do_text_output_multiline (tstate ,str -> data );
367- }
355+ if (stmt -> analyze )
356+ appendStringInfo (str ,"Total runtime: %.3f ms\n" ,
357+ 1000.0 * totaltime );
358+ do_text_output_multiline (tstate ,str -> data );
368359
369360pfree (str -> data );
370361pfree (str );
@@ -667,32 +658,30 @@ explain_outNode(StringInfo str,
667658default :
668659break ;
669660}
670- if (es -> printCost )
671- {
672- appendStringInfo (str ," (cost=%.2f..%.2f rows=%.0f width=%d)" ,
673- plan -> startup_cost ,plan -> total_cost ,
674- plan -> plan_rows ,plan -> plan_width );
661+
662+ appendStringInfo (str ," (cost=%.2f..%.2f rows=%.0f width=%d)" ,
663+ plan -> startup_cost ,plan -> total_cost ,
664+ plan -> plan_rows ,plan -> plan_width );
675665
676- /*
677- * We have to forcibly clean up the instrumentation state because
678- * we haven't done ExecutorEnd yet. This is pretty grotty ...
679- */
680- if (planstate -> instrument )
681- InstrEndLoop (planstate -> instrument );
666+ /*
667+ * We have to forcibly clean up the instrumentation state because
668+ * we haven't done ExecutorEnd yet. This is pretty grotty ...
669+ */
670+ if (planstate -> instrument )
671+ InstrEndLoop (planstate -> instrument );
682672
683- if (planstate -> instrument && planstate -> instrument -> nloops > 0 )
684- {
685- double nloops = planstate -> instrument -> nloops ;
673+ if (planstate -> instrument && planstate -> instrument -> nloops > 0 )
674+ {
675+ double nloops = planstate -> instrument -> nloops ;
686676
687- appendStringInfo (str ," (actual time=%.3f..%.3f rows=%.0f loops=%.0f)" ,
688- 1000.0 * planstate -> instrument -> startup /nloops ,
689- 1000.0 * planstate -> instrument -> total /nloops ,
690- planstate -> instrument -> ntuples /nloops ,
691- planstate -> instrument -> nloops );
692- }
693- else if (es -> printAnalyze )
694- appendStringInfo (str ," (never executed)" );
677+ appendStringInfo (str ," (actual time=%.3f..%.3f rows=%.0f loops=%.0f)" ,
678+ 1000.0 * planstate -> instrument -> startup /nloops ,
679+ 1000.0 * planstate -> instrument -> total /nloops ,
680+ planstate -> instrument -> ntuples /nloops ,
681+ planstate -> instrument -> nloops );
695682}
683+ else if (es -> printAnalyze )
684+ appendStringInfo (str ," (never executed)" );
696685appendStringInfoChar (str ,'\n' );
697686
698687/* quals, sort keys, etc */