wrong units in ExplainPropertyFloat - Mailing list pgsql-hackers

From Justin Pryzby
Subject wrong units in ExplainPropertyFloat
Date
Msg-id 20210415163846.GA3315@telsasoft.com
Whole thread Raw
Responses Re: wrong units in ExplainPropertyFloat  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
|commit 7a50bb690b4837d29e715293c156cff2fc72885c
|Author: Andres Freund <andres@anarazel.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



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Replacing pg_depend PIN entries with a fixed range check
Next
From: Mark Dilger
Date:
Subject: Re: pg_amcheck contrib application