size2

Got it — here’s a query for Aurora PostgreSQL that will list schema name, table name, and size in GB for all regular tables, largest first:

SELECT
    nspname AS schema_name,
    relname AS table_name,
    ROUND(pg_total_relation_size(pg_class.oid) / 1024.0 / 1024.0 / 1024.0, 2) AS size_gb
FROM
    pg_class
JOIN
    pg_namespace ON pg_namespace.oid = pg_class.relnamespace
WHERE
    relkind = 'r'  -- only regular tables
    AND nspname NOT IN ('pg_catalog', 'information_schema')
ORDER BY
    pg_total_relation_size(pg_class.oid) DESC;

Details:

  • pg_total_relation_size() → table + indexes + toast data
  • Division by 1024³ converts bytes → GB
  • ROUND(..., 2) → keeps only two decimal places
  • Excludes PostgreSQL system schemas

If you want parent partition sizes to include child partitions, we’d need to adjust this query.
Do you want me to give you that version too? That’s important if your Aurora Postgres has partitioned tables.

Comments

Popular posts from this blog

blocking query