0

How can i select the unallocated space and the free space of the database on PostgreSql. I used this query to get the Size of databases.

SELECT pg_database.datname, pg_database_size(pg_database.datname), pg_size_pretty(pg_database_size(pg_database.datname)) 
FROM pg_database ;

I m new on PostgreSql and i m asking if there is a solution to get the same result of sp_spaceused on SqlServer using Postgresql

elbohli ali
  • 3
  • 1
  • 3
  • 1
    Postgres doesn't use a single container file per database (or per tablespace), so there isn't really something like "unallocated" or "free" space. –  Feb 03 '16 at 09:32

1 Answers1

0

As a_horse_with_no_name said, there isn't a concept of 'Free Space' in PostgreSQL, since any usable Disk space is effectively Free Space for all databases on that machine, and if you look at this Stack-Overflow post, you'd understand why calculating 'Free Disk Space' is not simple.

If you are looking for an exact match (for e.g. when doing a SQL Server migration to PostgreSQL), you probably should see if this verbatim replacement even makes sense, and if it does, replace such columns with a realistic fallback (probably NULL?) and ensure compatibility / similarity in other columns.

Community
  • 1
  • 1
Robins Tharakan
  • 2,209
  • 19
  • 17