In this article, we have explained how to decide the size of PostgreSQL databases and tables.
Follow the steps to decide the size of PostgreSQL database and tables:
- Using SSH, log in to your account.
- Open the command line interface.
- Substitute dbname with the name of the database and username with the database username. Execute the following command:
psql dbname username
- Enter the database user’s password on the password prompt. If you enter the right password, the psql prompt appears.
- To decide the size of a database, execute the following command:
Note- Substitute dbname with the name of the database that you wish to check.
SELECT pg_size_pretty( pg_database_size(‘dbname’) );
- Psql shows the size of the database.
- To decide the size of the table in the current database, execute the following command.
Note- Substitute table name with the name of the table that you wish to check:
SELECT pg_size_pretty( pg_total_relation_size(‘tablename’) );
- Psql shows the size of the table.
This was the easiest way to decide the size of PostgreSQL databases and tables. If you want any type of assistance, do contact our support experts. They will definitely help you out. For more such informative articles, do visit our KB section regularly.