How to monitor/list outgoing connections to foreign servers in postgres?

476 views Asked by At

I currently use the native foreign data wrapper extension to connect to some other postgres instances (sharding architecture). Now I would like to understand how those underlying outgoing connections are managed by the fdw. I read in the documentation that libpq is used to handle the connections. There is no connection pooling in place but those connections are cached.

This connection is kept and re-used for subsequent queries in the same session.

I would like to list those connections to monitor those? We can list incoming connections via SELECT * FROM pg_stat_activity; - can we do something similar for outgoing connections?

1

There are 1 answers

0
Laurenz Albe On

The connections to the foreign server are kept open until the database session ends. To monitor that, set log_connections and log_disconnections to on on the target PostgreSQL server.