Updated on 2025-09-18 GMT+08:00

Database Object Size Functions

pg_table_size(regclass)

Description: Retrieves the table size and calculates the total size of all files in the table directory.

Return type: int64.

pg_table_files(regclass)

Description: Retrieves the table size and returns the paths and sizes of all files in the table directory.

Return type:

  • file_path: file path, which is of the text type.
  • file_name: file name, which is of the text type.
  • file_size: file size, which is of the int64 type.

pg_size_pretty(bigint)

Description: Converts the byte-calculated size into a human-readable size.

Return type: text.

pg_size_pretty(numeric)

Description: Converts the numerically represented byte-calculated size into a human-readable size.

Return type: text.

Note: pg_size_pretty formats the results of other functions into a human-readable format, using KB, MB, GB, or TB as appropriate.