Re: pg_size_pretty, SHOW, and spaces - Mailing list pgsql-hackers

From Christoph Berg
Subject Re: pg_size_pretty, SHOW, and spaces
Date
Msg-id 20160802092901.xg5ag7emdxoajhds@msg.df7cb.de
Whole thread Raw
In response to Re: pg_size_pretty, SHOW, and spaces  (Bruce Momjian <bruce@momjian.us>)
Responses Re: pg_size_pretty, SHOW, and spaces  (Bruce Momjian <bruce@momjian.us>)
List pgsql-hackers
Re: Peter Eisentraut 2016-08-01 <f3e021d3-d843-04a5-d816-6921309b3bf1@2ndquadrant.com>
> > PostgreSQL uses the spaces inconsistently, though. pg_size_pretty uses spaces:
> > 
> > # select pg_size_pretty((2^20)::bigint);
> >  pg_size_pretty
> > ────────────────
> >  1024 kB
> 
> because it's "pretty" :)

:)

> > SHOW does not:
> > 
> > # show work_mem;
> >  work_mem
> > ──────────
> >  1MB
> 
> The original idea might have been to allow that value to be passed back
> into the settings system, without having to quote the space.  I'm not
> sure, but I think changing that might cause some annoyance.

That's a good argument for keeping it that way, yes.


Re: Bruce Momjian 2016-08-01 <20160801162508.GA28246@momjian.us>
> Looking at the Wikipedia article I posted earlier, that also doesn't use
> spaces:
> 
>     https://en.wikipedia.org/wiki/Binary_prefix

That article has plenty of occurrences of "10 MB" "528 MB/s" and the
like.

> I think the only argument _for_ spaces is the output of pg_size_pretty()
> now looks odd, e.g.:
> 
>                10 | 10 bytes       | -10 bytes
>              1000 | 1000 bytes     | -1000 bytes
>           1000000 | 977KB          | -977KB
>        1000000000 | 954MB          | -954MB
>     1000000000000 | 931GB          | -931GB
>  1000000000000000 | 909TB          | -909TB
>                     ^^^^^             ^^^^^
> 
> The issue is that we output "10 bytes", not "10bytes", but for units we
> use "977KB".  That seems inconsistent, but it is the normal policy
> people use.  I think this is because "977KB" is really "977K bytes", but
> we just append the "B" after the "K" for bevity.

It's the other way round:

https://en.wikipedia.org/wiki/International_System_of_Units#General_rules

| The value of a quantity is written as a number followed by a space
| (representing a multiplication sign) and a unit symbol; e.g., 2.21 kg
[...]

I'd opt to omit the space anywhere where the value is supposed to be
fed back into the config (SHOW, --parameters), but use the "pretty"
format with space everywhere otherwise (documentation, memory counts
in explain output, pg_size_pretty() etc.)

Christoph



pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: Reviewing freeze map code
Next
From: Geoff Winkless
Date:
Subject: Re: Why we lost Uber as a user