How to get actually allocated tablespace size by each postgres database? Postgres tablespace is cluster-wide. Therefore, how do I caculated how much space allocated by each database in postgres tablespace ?
To get the disk space occupied by a database (nicely formatted):

SELECT pg_size_pretty(pg_database_size('mydb'))


Disk space occupied by a tablespace:

SELECT pg_size_pretty(pg_tablespace_size('mytblspace'))


Find out more about database object size functions in the manual: