Re: About pg_stat_activity

From: Greg Smith <greg(at)2ndquadrant(dot)com>
To: Cesar Arrieta <cesar(dot)cba(at)gmail(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: About pg_stat_activity
Date: 2011-02-02 17:24:26
Message-ID: 4D49934A.6010104@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

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(at)2ndQuadrant(dot)com Baltimore, MD
PostgreSQL Training, Services, and 24x7 Support www.2ndQuadrant.us
"PostgreSQL 9.0 High Performance": http://www.2ndQuadrant.com/books

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Benjamin Krajmalnik 2011-02-02 17:46:06 Re: Configuration for a new server.
Previous Message Robert Haas 2011-02-02 17:19:08 Re: [HACKERS] Slow count(*) again...