postgres rds large difference between database size on disk and actual tables size

16 Views Asked by At

I am encountering a weird scenario where when I do the following query:

SELECT
    pg_size_pretty(pg_database_size('MY_DB')) AS total_database_size;

I get 459GB , but when I query the individual size of the indexes and the tables I only get a fraction of the size, the sum of the query below is than 10GB. Using this query:

SELECT nspname || '.' || relname AS "relation",
    pg_size_pretty(pg_relation_size(C.oid)) AS "size"
  FROM pg_class C
  LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)
  WHERE nspname NOT IN ('pg_catalog', 'information_schema')
  ORDER BY pg_relation_size(C.oid) DESC;

I tried to vacuum analyse and it didn't help.

Why my storage is so bloated ?

Additional information the might help:

  1. I am using DBT, it does create temporary tables but it wasn't running so I don't think it had any affect
  2. I am importing data using Fivetran.
0

There are 0 best solutions below