How to determine the size of PostgreSQL databases and tables?

psql command-line program is used to determine the sizes of PostgreSQL databases and tables.

Log in to your Hostginger hosting account.

Type the following command at the command line. Replace dbname with the name of the database, and username with the database username: 

psql dbname username

When you type the correct password at the PASSWORD prompt, the psql prompt appears.

The following command determines the size of a database. Replace dbname with the name of the database of which you want to determine the size:
SELECT pg_size_pretty( pg_database_size('dbname') );

To determine the size of a table in the database, type the following command. Replace tablename with the name of the table that you want to determine:
SELECT pg_size_pretty( pg_total_relation_size('tablename') );



 

 

 

Was this answer helpful?

Related Articles

How to connect PostgreSQL using psql?

Log in to your Hostginger hosting account. Replace 'dbname' with the name of the database, and...

How to connect to PostgreSQL using PHP native functions?

Use the PHP code to connect to PostgreSQL and select a database. Replace 'username' with your...

How to connect to PostgreSQL using PDO (PHP Data Objects)?

PHP Data focus upon abstract database access, and enables you to use code that can handle...

How to connect to PostgreSQL using Python psycopg2 package?

To access PostgreSQL databases using Python, you must install psycopg2 package in a virtual...

How to connect to PostgreSQL using Python PyGreSQL?

To access PostgreSQL databases using Python, you must install PyGreSQL package in a virtual...