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)`.