X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 5980DD1B520 for ; Mon, 24 Nov 2003 20:51:38 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 31925-08 for ; Mon, 24 Nov 2003 16:51:12 -0400 (AST) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id 95B73D1D640 for ; Mon, 24 Nov 2003 16:51:10 -0400 (AST) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.12.9/8.12.9) with ESMTP id hAOKpANu040330 for ; Mon, 24 Nov 2003 20:51:10 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id hAOKW5nT037356 for pgsql-admin@postgresql.org; Mon, 24 Nov 2003 20:32:05 GMT From: =?ISO-8859-1?Q?Bj=F6rn?= Lundin X-Newsgroups: comp.databases.postgresql.admin Subject: Re: Associating client PIDs with backend PIDs Date: Mon, 24 Nov 2003 21:34:36 +0100 Organization: Hub.Org Networking Services Lines: 33 Message-ID: References: <3FC237EB.3050302@sysd.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8Bit X-Complaints-To: usenet@news.hub.org User-Agent: KNode/0.7.2 To: pgsql-admin@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200311/414 X-Sequence-Number: 11401 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@sysd.com > > > ---------------------------(end of broadcast)--------------------------- > TIP 8: explain analyze is your friend