Re: BUG #19456: # Unit-Labeling Issue: `pg_size_pretty()` Incorrectly Labels Binary Units as Decimal Units

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: gautamkumar2764(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #19456: # Unit-Labeling Issue: `pg_size_pretty()` Incorrectly Labels Binary Units as Decimal Units
Date: 2026-04-15 15:19:02
Message-ID: CAKFQuwa+ax2T6V1+FRf2CriNJVRKk-Md2eWYWRiGXxMompTRhg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Wed, Apr 15, 2026 at 7:48 AM PG Bug reporting form <
noreply(at)postgresql(dot)org> wrote:

> The following bug has been logged on the website:
>
> Bug reference: 19456
> Logged by: GAUTAM KUMAR
> Email address: gautamkumar2764(at)gmail(dot)com
> PostgreSQL version: 16.8
> Operating system: LINUX
> Description:
>
> The function appears to calculate sizes using binary (base-2) division
>

You don't need to infer this, you can just read the documentation.

"Converts a size in bytes into a more easily human-readable format with
size units (bytes, kB, MB, GB, TB, or PB as appropriate). Note that the
units are powers of 2 rather than powers of 10, so 1kB is 1024 bytes, 1MB
is 10242 = 1048576 bytes, and so on."

https://www.postgresql.org/docs/current/functions-admin.html#FUNCTIONS-ADMIN-DBOBJECT

Which means it is not a bug. And it's not the kind of behavior we are
going to change on people.

Maybe go write and submit a pg_size_iso(byte_count [, basis 2|10 default
10]) function. I agree this is a gap that could be addressed.

I'd probably drop the pg_ prefix as well - that always just seemed odd to
me. We have plenty of functions that are non-standard that we don't prefix
like this.

David J.

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Masahiko Sawada 2026-04-15 20:50:01 Re: TRAP: failed Assert("offsets[i] > offsets[i - 1]"), File: "tidstore.c"
Previous Message Andrei Lepikhov 2026-04-15 12:48:35 TRAP: failed Assert("offsets[i] > offsets[i - 1]"), File: "tidstore.c"