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:
- I am using DBT, it does create temporary tables but it wasn't running so I don't think it had any affect
- I am importing data using Fivetran.