diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c index 5d1f7089da..954f64b802 100644 --- a/src/backend/commands/explain.c +++ b/src/backend/commands/explain.c @@ -1624,13 +1624,21 @@ ExplainNode(PlanState *planstate, List *ancestors, if (es->format == EXPLAIN_FORMAT_TEXT) { if (es->timing) + { + appendStringInfo(es->str, " (actual time=%.3f..%.3f", + startup_ms, total_ms); appendStringInfo(es->str, - " (actual time=%.3f..%.3f rows=%.0f loops=%.0f)", - startup_ms, total_ms, rows, nloops); + nloops == 1 ? " rows=%.0f loops=%.0f" : + " rows=%.2f loops=%.0f)", + rows, nloops); + } else + { appendStringInfo(es->str, - " (actual rows=%.0f loops=%.0f)", - rows, nloops); + nloops == 1 ? + " (actual rows=%.0f loops=%.0f": " rows=%.2f loops=%.0f)", + rows, nloops); + } } else { @@ -1641,7 +1649,7 @@ ExplainNode(PlanState *planstate, List *ancestors, ExplainPropertyFloat("Actual Total Time", "ms", total_ms, 3, es); } - ExplainPropertyFloat("Actual Rows", NULL, rows, 0, es); + ExplainPropertyFloat("Actual Rows", NULL, rows, nloops == 1 ? 0 : 2, es); ExplainPropertyFloat("Actual Loops", NULL, nloops, 0, es); } } @@ -1690,13 +1698,20 @@ ExplainNode(PlanState *planstate, List *ancestors, { ExplainIndentText(es); if (es->timing) - appendStringInfo(es->str, - "actual time=%.3f..%.3f rows=%.0f loops=%.0f\n", - startup_ms, total_ms, rows, nloops); + { + appendStringInfo(es->str, "actual time=%.3f..%.3f", + startup_ms, total_ms); + appendStringInfo(es->str, + nloops == 1 ? " rows=%.0f loops=%.0f" : + " rows=%.2f loops=%.0f", + rows, nloops); + } else - appendStringInfo(es->str, - "actual rows=%.0f loops=%.0f\n", - rows, nloops); + { + appendStringInfo(es->str, nloops == 1 ? + "actual rows=%.0f loops=%.0f": " rows=%.2f loops=%.0f", + rows, nloops); + } } else { @@ -1707,7 +1722,7 @@ ExplainNode(PlanState *planstate, List *ancestors, ExplainPropertyFloat("Actual Total Time", "ms", total_ms, 3, es); } - ExplainPropertyFloat("Actual Rows", NULL, rows, 0, es); + ExplainPropertyFloat("Actual Rows", NULL, rows, nloops == 1 ? 0 : 2, es); ExplainPropertyFloat("Actual Loops", NULL, nloops, 0, es); } diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c index ce12915592..baecc40e0c 100644 --- a/src/backend/nodes/outfuncs.c +++ b/src/backend/nodes/outfuncs.c @@ -1937,7 +1937,7 @@ _outPathInfo(StringInfo str, const Path *node) WRITE_BOOL_FIELD(parallel_aware); WRITE_BOOL_FIELD(parallel_safe); WRITE_INT_FIELD(parallel_workers); - WRITE_FLOAT_FIELD(rows, "%.0f"); + WRITE_FLOAT_FIELD(rows, "%.2f"); WRITE_FLOAT_FIELD(startup_cost, "%.2f"); WRITE_FLOAT_FIELD(total_cost, "%.2f"); WRITE_NODE_FIELD(pathkeys);