mirror of
https://github.com/postgres/postgres.git
synced 2025-06-30 21:42:05 +03:00
Allow EXPLAIN to indicate fractional rows.
When nloops > 1, we now display two digits after the decimal point, rather than none. This is important because what we print is actually planstate->instrument->ntuples / nloops, and sometimes what you want to know is planstate->instrument->ntuples. You can estimate that by multiplying the displayed row count by the displayed nloops value, but the fact that the displayed value is rounded makes that inexact. It's still inexact even if we show these two extra decimal places, but less so. Perhaps we will agree on a way to further improve this output later, but for now this seems better than doing nothing. Author: Ibrar Ahmed <ibrar.ahmad@gmail.com> Author: Ilia Evdokimov <ilya.evdokimov@tantorlabs.com> Reviewed-by: David G. Johnston <david.g.johnston@gmail.com> Reviewed-by: Amit Kapila <amit.kapila16@gmail.com> Reviewed-by: Vignesh C <vignesh21@gmail.com> Reviewed-by: Greg Stark <stark@mit.edu> Reviewed-by: Naeem Akhter <akhternaeem@gmail.com> Reviewed-by: Hamid Akhtar <hamid.akhtar@percona.com> Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Reviewed-by: Andrei Lepikhov <a.lepikhov@postgrespro.ru> Reviewed-by: Guillaume Lelarge <guillaume@lelarge.info> Reviewed-by: Matheus Alcantara <matheusssilv97@gmail.com> Reviewed-by: Alena Rybakina <a.rybakina@postgrespro.ru> Discussion: http://postgr.es/m/603c8f070905281830g2e5419c4xad2946d149e21f9d%40mail.gmail.com
This commit is contained in:
@ -1993,14 +1993,15 @@ ExplainNode(PlanState *planstate, List *ancestors,
|
||||
|
||||
if (es->format == EXPLAIN_FORMAT_TEXT)
|
||||
{
|
||||
appendStringInfo(es->str, " (actual ");
|
||||
|
||||
if (es->timing)
|
||||
appendStringInfo(es->str,
|
||||
" (actual time=%.3f..%.3f rows=%.0f loops=%.0f)",
|
||||
startup_ms, total_ms, rows, nloops);
|
||||
appendStringInfo(es->str, "time=%.3f..%.3f ", startup_ms, total_ms);
|
||||
|
||||
if (nloops > 1)
|
||||
appendStringInfo(es->str, "rows=%.2f loops=%.0f)", rows, nloops);
|
||||
else
|
||||
appendStringInfo(es->str,
|
||||
" (actual rows=%.0f loops=%.0f)",
|
||||
rows, nloops);
|
||||
appendStringInfo(es->str, "rows=%.0f loops=%.0f)", rows, nloops);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2011,8 +2012,16 @@ ExplainNode(PlanState *planstate, List *ancestors,
|
||||
ExplainPropertyFloat("Actual Total Time", "ms", total_ms,
|
||||
3, es);
|
||||
}
|
||||
ExplainPropertyFloat("Actual Rows", NULL, rows, 0, es);
|
||||
ExplainPropertyFloat("Actual Loops", NULL, nloops, 0, es);
|
||||
if (nloops > 1)
|
||||
{
|
||||
ExplainPropertyFloat("Actual Rows", NULL, rows, 2, es);
|
||||
ExplainPropertyFloat("Actual Loops", NULL, nloops, 0, es);
|
||||
}
|
||||
else
|
||||
{
|
||||
ExplainPropertyFloat("Actual Rows", NULL, rows, 0, es);
|
||||
ExplainPropertyFloat("Actual Loops", NULL, nloops, 0, es);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (es->analyze)
|
||||
@ -2064,14 +2073,14 @@ ExplainNode(PlanState *planstate, List *ancestors,
|
||||
if (es->format == EXPLAIN_FORMAT_TEXT)
|
||||
{
|
||||
ExplainIndentText(es);
|
||||
appendStringInfo(es->str, "actual ");
|
||||
if (es->timing)
|
||||
appendStringInfo(es->str,
|
||||
"actual time=%.3f..%.3f rows=%.0f loops=%.0f\n",
|
||||
startup_ms, total_ms, rows, nloops);
|
||||
appendStringInfo(es->str, "time=%.3f..%.3f", startup_ms, total_ms);
|
||||
|
||||
if (nloops > 1)
|
||||
appendStringInfo(es->str, "rows=%.2f loops=%.0f\n", rows, nloops);
|
||||
else
|
||||
appendStringInfo(es->str,
|
||||
"actual rows=%.0f loops=%.0f\n",
|
||||
rows, nloops);
|
||||
appendStringInfo(es->str, "rows=%.0f loops=%.0f\n", rows, nloops);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2082,8 +2091,17 @@ ExplainNode(PlanState *planstate, List *ancestors,
|
||||
ExplainPropertyFloat("Actual Total Time", "ms",
|
||||
total_ms, 3, es);
|
||||
}
|
||||
ExplainPropertyFloat("Actual Rows", NULL, rows, 0, es);
|
||||
ExplainPropertyFloat("Actual Loops", NULL, nloops, 0, es);
|
||||
|
||||
if (nloops > 1)
|
||||
{
|
||||
ExplainPropertyFloat("Actual Rows", NULL, rows, 2, es);
|
||||
ExplainPropertyFloat("Actual Loops", NULL, nloops, 0, es);
|
||||
}
|
||||
else
|
||||
{
|
||||
ExplainPropertyFloat("Actual Rows", NULL, rows, 0, es);
|
||||
ExplainPropertyFloat("Actual Loops", NULL, nloops, 0, es);
|
||||
}
|
||||
}
|
||||
|
||||
ExplainCloseWorker(n, es);
|
||||
|
Reference in New Issue
Block a user