Sean Chittenden <sean@chittenden.org> writes:
> I can already identify that. Using the PID of the backend + sockstat
> on both the DB server and on the remote www server I can get the PID
> of the webserver process causing the problem, but I have no clue which
> customer, which page, which query, etc. The www process is doing
> something along the lines of:
> BEGIN;
> SELECT....
> [waits forever]
> END;
Oh, you want to know the actual current query. Turn on
stats_command_string or whatever it's called. See the statistics
collector documentation.
If this is after-the-fact (ie, you want to know about a process that's
hung right now), attach to it with a debugger and print out
debug_query_string.
regards, tom lane