> ## Documentation Index
> Fetch the complete documentation index at: https://kb.hosting.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Determining the size of PostgreSQL databases and tables

> Learn to determine PostgreSQL database and table sizes using psql or phpPgAdmin with this guide.

This article demonstrates how to determine the size of PostgreSQL databases and tables. You can do this by using the *psql* command-line program (for databases and tables) or by using the phpPgAdmin web interface (for databases only).

## Using the command line

You can use the *psql* command-line program to determine the sizes of PostgreSQL databases and tables. To do this, follow these steps:

1. Log in to your account [using SSH](/docs/using-ssh-secure-shell).

2. At the command line, type the following command. Replace *dbname* with the name of the database, and *username* with the database username:

   ```bash theme={null}
   psql dbname username
   ```

3. At the **Password** prompt, type the database user's password. When you type the correct password, the psql prompt appears.

4. To determine the size of a database, type the following command. Replace *dbname* with the name of the database that you want to check:

   ```sql theme={null}
   SELECT pg_size_pretty( pg_database_size('dbname') );
   ```

   Psql displays the size of the database.

5. To determine the size of a table in the current database, type the following command. Replace *tablename* with the name of the table that you want to check:

   ```sql theme={null}
   SELECT pg_size_pretty( pg_total_relation_size('tablename') );
   ```

   Psql displays the size of the table.

## Using phpPgAdmin

You can use the phpPgAdmin web interface to determine the sizes of PostgreSQL databases. To determine the sizes of PostgreSQL tables, however, you must use the *psql* command-line program as described in the previous section.

To determine the size of a PostgreSQL database using phpPgAdmin, follow these steps:

1. Log in to cPanel.
   > 📘 Note
   >
   > If you do not know how to log in to your cPanel account, please see [this article](/docs/accessing-cpanel).

2. In the **DATABASES** section of the cPanel home screen, click **phpPgAdmin**:\
   ![cPanel - Databases - phyPgAdmin icon](https://static.hosting.com/kb/kb-cpanel-78-databases-phppgadmin-icon.png)

   The phpPgAdmin administration page appears in a new window.

3. In the left pane, click **PostgreSQL**:\
   ![phpPgAdmin - Left pane](https://static.hosting.com/kb/kb-phppgadmin-left-pane.png)

4. phpPgAdmin displays the size of each database:\
   ![phpPgAdmin - Right pane](https://static.hosting.com/kb/kb-phppgadmin-right-pane.png)

## Related articles

* [Accessing phpMyAdmin and phpPgAdmin](/docs/phpmyadmin-and-phppgadmin)

* [Connecting to PostgreSQL using psql](/docs/connect-to-postgresql-from-the-command-line)
