pg_size_pretty()
PostgreSQL
When I was looking into moving large numbers of files around recently, I found myself checking the content_length and constantly running the same calculation to get size in GB:
content_length = 387229741228 # bytes
bytes_per_gb = 1073741824
content_length / bytes_per_gb
=> 360
Then I was told about the in-built PostgreSQL function pg_size_pretty(), which can be used like so:
SELECT pg_size_pretty(387229741228);
pg_size_pretty
----------------
361 GB
(1 row)
You can find more information in the official PostgreSQL documentation