NeonN
Neon2y ago
9 replies
then-purple

How can I see what consumes the storage in my database?

A few hours ago I saw that I had exceeded +/- 14MB of NeonDB's storage limit (512MB), so I decided to delete some unused data from old versions, which are no longer used, around ~26,000 rows were deleted, so I went to lunch

So I went back now and saw that my storage usage did not decrease, but increased from 526/512MB to 617/512MB, and the query I use does not reflect this entire size, I wanted to know if there is any query where I can better see the usage of storage for these tables, I wanted to know where these 600MB+ are allocated, or if there are any tools in Neon for this...

The query I usually use:
SELECT 
    schema_table AS "schema.table", 
    pg_size_pretty(pg_relation_size(schema_table)) AS table_size, 
    pg_size_pretty(pg_indexes_size(schema_table)) AS index_size, 
    pg_size_pretty(pg_total_relation_size(schema_table)) AS total_size 
FROM (
    SELECT schemaname || '.' || tablename AS schema_table 
    FROM pg_catalog.pg_tables 
    WHERE schemaname NOT IN ('pg_catalog', 'information_schema', 'pg_toast')
) AS x 
ORDER BY
    pg_total_relation_size(schema_table) DESC;
image.png
image.png
Was this page helpful?