How to get actually allocated tablespace size by each postgres database?
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: