Overview

The pg_size_pretty() is a database object management function that converts sizes in bytes into a human-readable format.

Syntax

The syntax for the pg_size_pretty() function is as follows:

pg_size_pretty(size)

Parameters

The following parameters are required to execute this function:

  • size: specifies the size in bytes that you want to convert

Examples

SELECT pg_size_pretty(100);
 pg_size_pretty
----------------
 100 bytes
(1 row)
SELECT pg_size_pretty(1000000);
 pg_size_pretty
----------------
 977 kB
(1 row)