Skip to main content

Overview

The pg_total_relation_size() is a database object size function that retrieves the size of a table and is useful for monitoring the storage requirements.

Syntax

The syntax for the pg_total_relation_size() function is as follows:
It returns the size of the specified table in bytes.

Parameters

The following parameters are required to execute this function:
  • relation_name: name of the table for which you want to determine the size

Example

For the needs of this section, we will create a users table
Now we would like to use the pg_total_relation_size() function to determine the size of the users table (in bytes)
By executing the query above, we will get the following output: