What parts make up pg_database_size?
You are counting the toast tables twice.  Once under their owner, as pg_total_relation_size(reltoastrelid), and again under their own entry in pg_class.  You should use relkind, not reltype, to filter what you want.

Also, trying to micromanage your RDBMS to this extent rarely pays off.