SQL Reference
...
SQL Functions
Other Functions
pg_total_relation_size
6min
The pg_total_relation_size function allows you to retrieve the size of a table. This function is useful for monitoring the storage requirements.
The syntax for the pg_total_relation_size function is as follows:
Pgsql
|
ο»Ώ
Here, relation_name is the name of the table for which you want to determine the size.
The pg_total_relation_size function returns the size of the specified table in bytes.
1) First, letβs assume we have a table named users. Use the below query to create the table.
Pgsql
|
ο»Ώ
2) In this case, we will use the pg_total_relation_size function to determine the size of a users table.
Pgsql
|
ο»Ώ
3) This query will return the size of the users table in bytes.
Pgsql
|
ο»Ώ
ο»Ώ

Updated 13 Sep 2023
Did this page help you?