Re: Add support for unit "B" to pg_size_pretty()

From: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
To: David Rowley <dgrowleyml(at)gmail(dot)com>
Cc: Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>, Justin Pryzby <pryzby(at)telsasoft(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Add support for unit "B" to pg_size_pretty()
Date: 2023-03-03 12:22:38
Message-ID: CAEZATCXhckx67SNMduA9Qh=5Px2bkCp7oeW4M8+P54eWHdorgw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, 3 Mar 2023 at 11:23, David Rowley <dgrowleyml(at)gmail(dot)com> wrote:
>
> On Fri, 3 Mar 2023 at 09:32, Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> wrote:
> > Hmm, I think it would be easier to just have a separate table for
> > pg_size_bytes(), rather than reusing pg_size_pretty()'s table.
>
> Maybe that's worthwhile if we were actually thinking of adding any
> non-base 2 units in the future, but if we're not, perhaps it's better
> just to have the smaller alias array which for Peter's needs will just
> require 1 element + the NULL one instead of 6 + NULL.
>

Maybe. It's the tradeoff between having a smaller array and more code
(2 loops) vs a larger array and less code (1 loop).

> In any case, I'm not really sure I see what the path forward would be
> to add something like base-10 units would be for pg_size_bytes(). If
> we were to change MB to mean 10^6 rather than 2^20 I think many people
> would get upset.
>

Yeah, that's probably true. Given the way this and configuration
parameters currently work, I think we're stuck with 1MB meaning 2^20
bytes.

Regards,
Dean

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Hayato Kuroda (Fujitsu) 2023-03-03 12:24:52 RE: [Proposal] Add foreign-server health checks infrastructure
Previous Message Tomas Vondra 2023-03-03 12:14:42 Re: Missing update of all_hasnulls in BRIN opclasses