This guide shows you how to check the size of PostgreSQL databases and tables using the command line. You can utilize the ‘psql’ command-line tool to find the sizes of PostgreSQL databases and tables.

Follow these steps-

  1. Log in to your account via SSH.
  2. At the command prompt, enter the following command, substituting dbname with your database name and username with your database username-
    psql dbname username
  3. When prompted for a password, enter the password for the database user. After entering the correct password, the ‘psql’ prompt will appear.
  4. To find the size of a database, enter this command, replacing dbname with the name of the database you want to check-
    SELECT pg_size_pretty( pg_database_size('dbname') );

    ‘psql’ will display the database size.

  5. To find the size of a table in the current database, enter this command, replacing tablename with the name of the table you want to check-
    SELECT pg_size_pretty( pg_total_relation_size('tablename') );

    ‘psql’ will display the table size.

Hope you liked our article. If you liked our article then you will surely love our support. Our support team is available for you around the clock. You can learn more about How to Inspect the Sizes of MySQL Databases and Tables.

Popular Posts You May Read

Explore more hosting insights, tips and industry updates.

How do you enable FTP to be available to your server and users?

Brute force attacks, spoofing, and sniffing are all possible with FTP data. The protocol has…

WHM -litespeed and Apache

How to switch between LiteSpeed and Apache in WHM

In this tutorial, we’ll explain how to switch between Lite Speed and Apache in WHM.…

How to Block Bad Bots?

Before you proceed to block bad bots, you will need to know at least one…