wrong units in ExplainPropertyFloat

From: Justin Pryzby <pryzby(at)telsasoft(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: wrong units in ExplainPropertyFloat
Date: 2021-04-15 16:38:46
Message-ID: 20210415163846.GA3315@telsasoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

|commit 7a50bb690b4837d29e715293c156cff2fc72885c
|Author: Andres Freund <andres(at)anarazel(dot)de>
|Date: Fri Mar 16 23:13:12 2018 -0700
|
| Add 'unit' parameter to ExplainProperty{Integer,Float}.
|
| This allows to deduplicate some existing code, but mainly avoids some
| duplication in upcoming commits.
|
| In passing, fix variable names indicating wrong unit (seconds instead
| of ms).
|
| Author: Andres Freund
| Discussion: https://postgr.es/m/20180314002740.cah3mdsonz5mxney@alap3.anarazel.de

@@ -1304,8 +1299,8 @@ ExplainNode(PlanState *planstate, List *ancestors,
planstate->instrument && planstate->instrument->nloops > 0)
{
double nloops = planstate->instrument->nloops;
- double startup_sec = 1000.0 * planstate->instrument->startup / nloops;
- double total_sec = 1000.0 * planstate->instrument->total / nloops;
+ double startup_ms = 1000.0 * planstate->instrument->startup / nloops;
+ double total_ms = 1000.0 * planstate->instrument->total / nloops;
...
if (es->timing)
{
- ExplainPropertyFloat("Actual Startup Time", startup_sec, 3, es);
- ExplainPropertyFloat("Actual Total Time", total_sec, 3, es);
+ ExplainPropertyFloat("Actual Startup Time", "s", startup_ms,
+ 3, es);
+ ExplainPropertyFloat("Actual Total Time", "s", total_ms,
+ 3, es);

There's 3 pairs of these, and the other two pairs use "ms":

$ git grep 'Actual.*Time' src/backend/commands/explain.c
src/backend/commands/explain.c: ExplainPropertyFloat("Actual Startup Time", "s", startup_ms,
src/backend/commands/explain.c: ExplainPropertyFloat("Actual Total Time", "s", total_ms,
src/backend/commands/explain.c: ExplainPropertyFloat("Actual Startup Time", "ms", 0.0, 3, es);
src/backend/commands/explain.c: ExplainPropertyFloat("Actual Total Time", "ms", 0.0, 3, es);
src/backend/commands/explain.c: ExplainPropertyFloat("Actual Startup Time", "ms",
src/backend/commands/explain.c: ExplainPropertyFloat("Actual Total Time", "ms",

Text mode uses appendStringInfo() for high density output, so this only affects
non-text output, but it turns out that units aren't shown for nontext format
anyway - this seems like a deficiency, but it means there's no visible bug.

--
Justin

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Mark Dilger 2021-04-15 17:07:16 Re: pg_amcheck contrib application
Previous Message Tom Lane 2021-04-15 16:37:48 Re: Replacing pg_depend PIN entries with a fixed range check