Received: from localhost (unknown [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id E096A2E2DC1 for ; Thu, 13 Dec 2007 17:57:35 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 42952-07 for ; Thu, 13 Dec 2007 17:57:20 -0400 (AST) Received: from wa-out-1112.google.com (wa-out-1112.google.com [209.85.146.183]) by postgresql.org (Postfix) with ESMTP id 9ED912E0215 for ; Thu, 13 Dec 2007 17:57:29 -0400 (AST) Received: by wa-out-1112.google.com with SMTP id m38so1392089waf.5 for ; Thu, 13 Dec 2007 13:57:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=TdXiVPBoRg4hPjE1UKqnVeBD/DQgdWVUHOW5JGRxNLg=; b=ht3zFQXyns0QV66hUDPoPW3W/QPWAPNBPGKsBwwnkficX8UjJsx/nDHtDL2SEn3T7EboNiBub4GWNUssjykgx6kacQ/1mw+R3ccIVuIVMqZOWgdLzjRLnfG2ElFUWp0YrlztbwJyTgoidS/9ZWINeXeS9Ezrfi5JEd3YlWweS7c= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=CxYsmXrQeNnEJyASCFqoPLObYgeY2iWCkxAjbHo2XfvaZEmWMqHqYlSwDv0H58a2Dhn6RwPoXY5/vEwR57ykmFly+LMMJnAmFhdZ4mCzLa3ixeoH68kARGPMZmhZOe8GWPrtdO85kdQ7FMz7nO3O9CJ7ImW3H+EYv4qbylbJf0Q= Received: by 10.115.74.1 with SMTP id b1mr2826691wal.93.1197583047233; Thu, 13 Dec 2007 13:57:27 -0800 (PST) Received: by 10.114.131.4 with HTTP; Thu, 13 Dec 2007 13:57:27 -0800 (PST) Message-ID: Date: Thu, 13 Dec 2007 15:57:27 -0600 From: "Scott Marlowe" To: "Tena Sakai" Subject: Re: reading pg_stat_activity view Cc: pgsql-admin@postgresql.org In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200712/99 X-Sequence-Number: 27616 On Dec 13, 2007 3:43 PM, Tena Sakai wrote: > > My next question: > What would be a good way to tell if some > query is hung? That would really depend on what you mean by hung. Just running a really long time, or waiting for a lock that some other session is not will to commit / rollback like above? I take it you just mean long running queries. You can do a couple of things. You can set the value for statement_timeout and any statement that takes over that amount of time will generate a timeout and you then log it in the logs. You can use pg_stat_activity to see how long a query's been running. Something like select datname, usename, current_query, waiting, now() - query_start from pg_stat_activity order by query_start; can show you how long each query has been running.