I am trying to figure out as much as I can about what host a particular type of update query is coming from.
My database is PostgreSQL 9.0.23 locally running pgbouncer for connection pooling. The pooling type is transaction pooling.
A trigger in the database saving information from pg_stat_activity
tells me about the pgbouncer connection, but doesn't help me figure out who is behind that.
The database in question is a production database under load. Therefore removing pgbouncer is not an option. Having pgbouncer write a verbose log is probably also a bad idea.
Is there any reasonable way to find out which host the query ultimately comes from?
The way I use to keep tracking clients from pgbouncer is joining
pg_stat_statements
with pgbouncershow clients
command. Here is an example:(By all means you can use just dblink or just postgres_fdw - I use mix to support obsolete usage on prod... If you did not have any notes, just ignore that...)
Now we can join pgbouncer view with
pg_stat_statements
:Here
app - 10.10.10.10:24514
means this pid is from pgbouncer, and to pgbouncer it connected from 0.10.10.10