Skip to content

Determining the size of PostgreSQL databases and tables

PostgreSQL provides built‑in functions to check the size of databases and tables. On ruachost.com, you can use either the psql command line or the phpPgAdmin web interface to determine storage usage.

  • Monitor disk usage and prevent storage overages.
  • Identify large tables that may need optimization.
  • Plan for scaling and resource allocation.
Terminal window
ssh username@yourserver.ruachost.com

Terminal window
psql dbname username
Terminal window
SELECT pg_size_pretty(pg_database_size('dbname'));
  • Returns the total size of the database in a human‑readable format (e.g., MB, GB).
SELECT pg_size_pretty(pg_total_relation_size('tablename'));
  • Returns the size of a specific table, including indexes and related data.
  • Navigate to Databases → phpPgAdmin.
  • In the left pane, click PostgreSQL.
  • phpPgAdmin displays the size of each database.

???? Note: phpPgAdmin shows database sizes only. To check table sizes, you must use the psql command line.