Pretty byte size formatting in EXPLAIN - Mailing list pgsql-hackers

From Gavin Wahl
Subject Pretty byte size formatting in EXPLAIN
Date
Msg-id CACPudh2PLmZ2pbSYN5jmBirqW0Jv4U39qRyHR0ySpMMjEaDZMg@mail.gmail.com
Whole thread Raw
List pgsql-hackers
In EXPLAIN ANALYZE output, I find the disk/memory usage numbers to be
hard to read because they are always in kB. I'd like to have an option
to format them like pg_size_pretty does, choosing a more appropriate unit
based on the magnitude of the value being expressed. That is, instead of
`Batches: 1  Memory Usage: 163857kB`,
EXPLAIN (PRETTY) would show
`Batches: 1  Memory Usage: 160 MB`.

I see the formatting is done in src/backend/commands/explain.c, hardcoded
to kB. I understand the default output of EXPLAIN probably can't be
changed due to third-party tools that parse it, so I'd like to add an
option, something like PRETTY, to EXPLAIN, that would use pg_size_pretty
formatted values.

Would such a patch be accepted? If there's interest I can work on
writing it.

Also--while I think the pg_size_pretty improvement to be much more
important, so I don't want to derail this, I think thousands separators in
numbers would be useful as well, similar to `\pset numericlocale on`. Is
it possible for psql to do this conversion, or would another option to
EXPLAIN be necessary?  Something like EXPLAIN (NUMERICLOCAL) would show
`Sort (cost=71,270.98..72,104.31 rows=333,333 width=40)`
instead of
`Sort (cost=71270.98..72104.31 rows=333333 width=40)`.



pgsql-hackers by date:

Previous
From: "Matt Smith (matts3)"
Date:
Subject: Re: Meson install warnings when running postgres build from a sandbox
Next
From: Masahiko Sawada
Date:
Subject: Re: Add copyright notice to 048_vacuum_horizon_floor.pl