Postgresql – How to get the amount of free space with Postgresql

postgresql

I am using Postgres 9.3.16 and would like to found out how much free space there is with Postgres

How to get the amount of free space with Postgresql?

Best Answer

There's no such thing as free space in PostgreSQL: you only have free space available on the disk PostgreSQL is using to store its data. In PostgreSQL, you can find out the Disk Usage of your tables etc.

For free disk space you need to see the output of system command df. For security reasons you can't call these commands directly from PostgreSQL, but you may write an intermediate untrusted PL/Python function for that.

Notice that the space available may also be limited by a quota affecting the user running PostgreSQL server. See 29.2. Disk Full Failure.