X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A67A9545CA for ; Mon, 2 May 2005 00:04:54 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 18179-09 for ; Mon, 2 May 2005 03:04:52 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id DA51C545C6 for ; Mon, 2 May 2005 00:04:50 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j4234nKA009989; Sun, 1 May 2005 23:04:50 -0400 (EDT) To: Cosimo Streppone Cc: pgsql-sql@postgresql.org Subject: Re: pgtop, display PostgreSQL processes in `top' style In-reply-to: <42740256.4090200@streppone.it> References: <42740256.4090200@streppone.it> Comments: In-reply-to Cosimo Streppone message dated "Sun, 01 May 2005 00:10:30 +0200" Date: Sun, 01 May 2005 23:04:49 -0400 Message-ID: <9988.1115003089@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/2 X-Sequence-Number: 21315 Cosimo Streppone writes: > 1) is it possible to know Pg backend uptime with > SQL queries? Or must I look at postmaster.pid file? > or even something else? I suppose you mean postmaster uptime, not the lifespan of your own connection. We don't track that at the moment, but IIRC there is a patch in the queue to provide a function that returns this for 8.1. For now you could perhaps look at "ps" output to see how long the postmaster process has been running, but that's surely ugly and fraught with pitfalls ... Interesting thought here: should we track the postmaster process uptime, or the time since the last database restart? Not the same at all. You could argue that from a reliability standpoint the latter is the interesting number. > 2) how can I know the ip addresses/hostnames of clients > connecting to server? You can't (again, unless you want to parse "ps" output). But I think someone has submitted a patch to add such columns to the pg_stat_activity view. We need to figure out whether the visibility of these columns needs to be restricted for security, but pending that discussion it'll probably be in 8.1 in some form. > 3) Is there a way to know the number of queries performed > against Pg backend (by each client)? Can I distinguish > between selects / updates / inserts / copy / ... ? Nope, and nope. We could perhaps teach the stats collector to count querystrings it's received from each backend, which'd answer the first one to a reasonable extent. I'm unconvinced that we should expend the overhead to be able to do the second. regards, tom lane