ExplainProperty* and units - Mailing list pgsql-hackers

From Andres Freund
Subject ExplainProperty* and units
Date
Msg-id 20180314002740.cah3mdsonz5mxney@alap3.anarazel.de
Whole thread Raw
Responses Re: ExplainProperty* and units
Re: ExplainProperty* and units
Re: ExplainProperty* and units
List pgsql-hackers
Hi,

while adding EXPLAIN support for JITing (displaying time spent etc), I
got annoyed by the amount of duplication required. There's a fair amount
of
    if (es->format == EXPLAIN_FORMAT_TEXT)
        appendStringInfo(es->str, "Execution time: %.3f ms\n",
                                         1000.0 * totaltime);
    else
        ExplainPropertyFloat("Execution Time", 1000.0 * totaltime,
which is fairly redundant.

In the attached *POC* patch I've added a 'unit' parameter to the numeric
ExplainProperty* functions, which EXPLAIN_FORMAT_TEXT adds to the
output.  This can avoid the above and other similar branches (of which
the JIT patch would add a number).

The most valid counterargument I see is that in many cases, particularly
inside plans, we have more specific output for text mode anyway. Which
means there we'll not benefit much.  But I think that's a) considerably
done due to backward compatibility concerns b) verbosity concerns inside
plans, which obviously can be complicated.  Therefore I think it's
perfectly reasonable to avoid specific branches for data that's only
going to be displayed once per plan?

We also could add separate ExplainProperty*Unit(...) functions, but I
don't really see a need.

Comments?

Greetings,

Andres Freund

Attachment

pgsql-hackers by date:

Previous
From: Tatsuo Ishii
Date:
Subject: Re: Fixes for missing schema qualifications
Next
From: David Rowley
Date:
Subject: Re: ALTER TABLE ADD COLUMN fast default