Re: Associating client PIDs with backend PIDs

From: Björn Lundin <bjorn(dot)lundin(at)swipnet(dot)se>
To: pgsql-admin(at)postgresql(dot)org
Subject: Re: Associating client PIDs with backend PIDs
Date: 2003-11-24 20:34:36
Message-ID: bptps4$14fb$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Rich Cullingford wrote:

> All,
> This is a pretty obvious question, but I can't find an answer in the
> standard docs/archive: if I have an installation in which there are a
> number of long-running client processes interacting (one-on-one) with
> backend processes, how do I find the associations? I can see the client
> PIDs in an appropriate 'ps' (grepping on the client program name, for
> example), and the backend PIDs in the standard queries or pgmonitor. But
> I can't tell which goes with which (except by trying to infer the
> association by looking at the query that's running -- assuming I can
> catch it).

if your client uses libpq, you could use

PQbackendPID Returns the process ID of the backend server handling this
connection.

int PQbackendPID(const PGconn *conn);

to save the backend's pid to a known file after you connected

/Björn

>
> Thanks for any help,
> Rich Cullingford
> rculling(at)sysd(dot)com
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 8: explain analyze is your friend

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Robert Treat 2003-11-24 22:22:15 Re: Cannot read back pg_dump from 7.2 into 7.4
Previous Message Glenn Wiorek 2003-11-24 18:38:23 Re: How to interact with the db using java