PostgreSQL Storage Amounts

In an 8.3 db I estimated (in GB) by:

select min(relfilenode), max(relfilenode), sum(8.0 * relpages / (1024.0 * 1024.0)) FROM pg_class;
min | max | sum
——+———-+—————————–
1136 | 13217178 | 12.544336000000000000000000

The Same Process works for 9.3.

You can drill down to individual table requirements as follows:

select relname, round(sum(8.0 * relpages / (1024.0 * 1024.0))) as size_gb, round(sum(8.0 * relpages / 1024)) as size_mb FROM pg_class where relname not like 'pg_%' and relname not like 'sql_%' and relkind in ('r','t') group by relname order by relname;
 relname         | size_gb | size_mb
-----------------+---------+---------
 pcp             |       0 | 0
 ptest           |       0 | 0
 spatial_ref_sys |       0 | 3
 test            |       0 | 0
 test23z         |       0 | 0
(5 rows)

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s