Find Size of postgres dump file

Planing to take dump of PG database.

Before running dump, is there any way to find out the size of dump file of database ?

The database size currently in TBs

0 1 5,105
1 REPLY 1

Hi @Chandra,

If you have calculated your PG DB size using select pg_size_pretty(pg_database_size('dbname'));

then your size estimation could be wrong as this will give you size including outdated records as well as any other uncleaned data.

You could do a vacuum on your DB and check the size again.

Even after that, the export size may differ as pg_dump will just export the data into text which might result in lower size or may be higher based on the schema of DB. For example, a value '1' stored in a column with BIGINT will take 8 bytes in PG cluster where as it will be stored in the text with 1 byte similarly export of binary data from PG may result in more size when represented in text.

So there is no concrete way of figuring out the exact export size.

Although if you need to export a really large DB then perhaps you could use the split and gzip options.

Please refer the documentation here: https://www.postgresql.org/docs/9.1/static/backup-dump.html

Hope this is helpful!