Index: src/backend/commands/explain.c =================================================================== RCS file: /home/alvherre/cvs/pgsql/src/backend/commands/explain.c,v retrieving revision 1.135 diff -c -r1.135 explain.c *** src/backend/commands/explain.c 25 Apr 2005 01:30:12 -0000 1.135 --- src/backend/commands/explain.c 2 Jun 2005 18:35:26 -0000 *************** *** 38,44 **** typedef struct ExplainState { /* options */ - bool printCost; /* print cost */ bool printNodes; /* do nodeToString() too */ bool printAnalyze; /* print actual times */ /* other states */ --- 38,43 ---- *************** *** 238,244 **** es = (ExplainState *) palloc0(sizeof(ExplainState)); - es->printCost = true; /* default */ es->printNodes = stmt->verbose; es->printAnalyze = stmt->analyze; es->rtable = queryDesc->parsetree->rtable; --- 237,242 ---- *************** *** 258,275 **** pfree(s); do_text_output_multiline(tstate, f); pfree(f); ! if (es->printCost) ! do_text_output_oneline(tstate, ""); /* separator line */ } } str = makeStringInfo(); ! if (es->printCost) ! { ! explain_outNode(str, queryDesc->plantree, queryDesc->planstate, ! NULL, 0, es); ! } /* * If we ran the command, run any AFTER triggers it queued. (Note this --- 256,269 ---- pfree(s); do_text_output_multiline(tstate, f); pfree(f); ! do_text_output_oneline(tstate, ""); /* separator line */ } } str = makeStringInfo(); ! explain_outNode(str, queryDesc->plantree, queryDesc->planstate, ! NULL, 0, es); /* * If we ran the command, run any AFTER triggers it queued. (Note this *************** *** 350,362 **** totaltime += elapsed_time(&starttime); ! if (es->printCost) ! { ! if (stmt->analyze) ! appendStringInfo(str, "Total runtime: %.3f ms\n", ! 1000.0 * totaltime); ! do_text_output_multiline(tstate, str->data); ! } pfree(str->data); pfree(str); --- 344,353 ---- totaltime += elapsed_time(&starttime); ! if (stmt->analyze) ! appendStringInfo(str, "Total runtime: %.3f ms\n", ! 1000.0 * totaltime); ! do_text_output_multiline(tstate, str->data); pfree(str->data); pfree(str); *************** *** 659,690 **** default: break; } ! if (es->printCost) ! { ! appendStringInfo(str, " (cost=%.2f..%.2f rows=%.0f width=%d)", ! plan->startup_cost, plan->total_cost, ! plan->plan_rows, plan->plan_width); ! /* ! * We have to forcibly clean up the instrumentation state because ! * we haven't done ExecutorEnd yet. This is pretty grotty ... ! */ ! if (planstate->instrument) ! InstrEndLoop(planstate->instrument); ! if (planstate->instrument && planstate->instrument->nloops > 0) ! { ! double nloops = planstate->instrument->nloops; ! appendStringInfo(str, " (actual time=%.3f..%.3f rows=%.0f loops=%.0f)", ! 1000.0 * planstate->instrument->startup / nloops, ! 1000.0 * planstate->instrument->total / nloops, ! planstate->instrument->ntuples / nloops, ! planstate->instrument->nloops); ! } ! else if (es->printAnalyze) ! appendStringInfo(str, " (never executed)"); } appendStringInfoChar(str, '\n'); /* quals, sort keys, etc */ --- 650,679 ---- default: break; } ! ! appendStringInfo(str, " (cost=%.2f..%.2f rows=%.0f width=%d)", ! plan->startup_cost, plan->total_cost, ! plan->plan_rows, plan->plan_width); ! /* ! * We have to forcibly clean up the instrumentation state because ! * we haven't done ExecutorEnd yet. This is pretty grotty ... ! */ ! if (planstate->instrument) ! InstrEndLoop(planstate->instrument); ! if (planstate->instrument && planstate->instrument->nloops > 0) ! { ! double nloops = planstate->instrument->nloops; ! appendStringInfo(str, " (actual time=%.3f..%.3f rows=%.0f loops=%.0f)", ! 1000.0 * planstate->instrument->startup / nloops, ! 1000.0 * planstate->instrument->total / nloops, ! planstate->instrument->ntuples / nloops, ! planstate->instrument->nloops); } + else if (es->printAnalyze) + appendStringInfo(str, " (never executed)"); appendStringInfoChar(str, '\n'); /* quals, sort keys, etc */