Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id A6C6C1337B90 for ; Wed, 2 Feb 2011 13:24:38 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 85561-08 for ; Wed, 2 Feb 2011 17:24:31 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.17.8]) by mail.postgresql.org (Postfix) with ESMTP id 7F1241337B8D for ; Wed, 2 Feb 2011 13:24:29 -0400 (AST) Received: from [192.168.1.6] (mail.highperformancepostgresql.com [71.179.240.8]) by mrelayeu.kundenserver.de (node=mrbap1) with ESMTP (Nemesis) id 0La2aD-1QRDOr0dCf-00lSZc; Wed, 02 Feb 2011 18:24:28 +0100 Message-ID: <4D49934A.6010104@2ndquadrant.com> Date: Wed, 02 Feb 2011 12:24:26 -0500 From: Greg Smith User-Agent: Thunderbird 2.0.0.24 (X11/20100317) MIME-Version: 1.0 To: Cesar Arrieta CC: pgsql-performance@postgresql.org Subject: Re: About pg_stat_activity References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:XuQQewGIwpldgBA9DUCo8Rv27YILBWBkM+h88RfVhAB uuOH62/WoYbGz6/WXuGOcGYvrQKdPfz9qxB3kErH1nGD6Xe8is ucxySvs9q3Pvo5i/xqWmxOdyHPt0VdRKXjzhntfJyxSDjwTMCV GsoDKbvfWV0DgNJWrTukZdbpJh5W+65v80JTjjpqOY4zmw+xDm 5Zf0BTKwEqdwkhw0ootrpxJHADrGajoME2Td3unJFg= X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001 X-Spam-Level: X-Archive-Number: 201102/26 X-Sequence-Number: 42164 Cesar Arrieta wrote: > im developing an app that saves information included in > "pg_stat_activity" view in order to monitor querys. The objective of > this app is to gather information about querys that take to long to > finish and overload the server. I hope you're already setting log_min_duration_statement, then analyzing the resulting logs using something like pgFouine. If you have PostgreSQL 8.4 or later, possibly add loading the auto_explain module as well, or collecting the data using pg_stat_statements instead can be useful. Trying to grab this info in real-time from pg_stat_activity instead is a lot of work and won't give you results as good. If you're already doing something like that and are just looking to increase the amount of info you collect by also looking at pg_stat_activity, that can be worthwhile. Maciek just gave the quickest answer to your main question; I'll just add that reading the source code to the file system_views.sql will show you how pg_stat_activity as well as other interesting built-in views work. -- Greg Smith 2ndQuadrant US greg@2ndQuadrant.com Baltimore, MD PostgreSQL Training, Services, and 24x7 Support www.2ndQuadrant.us "PostgreSQL 9.0 High Performance": http://www.2ndQuadrant.com/books