Postgresql how to compare the tables which are present in different database
you could use the postgres_fdw to link the 2 dbs together and execute queries to compare the different tables as if they we're in the same db.

see the documentation on postgres_fdw for examples.
Note, this requires that you will be able to connect from one db to the other remotely. and queries might be resource intensive (as you are basically pulling the data of the remote table over the wire)