Re: investigating slow queries through pg_stat_activity - Mailing list pgsql-performance

From George Essig
Subject Re: investigating slow queries through pg_stat_activity
Date
Msg-id 6744b38505062013302b4f1864@mail.gmail.com
Whole thread Raw
In response to investigating slow queries through pg_stat_activity  (Dan Harris <fbsd@drivefaster.net>)
List pgsql-performance
On 6/20/05, Dan Harris <fbsd@drivefaster.net> wrote:
> Also, I'm sure some people will respond with "turn on query
> logging".. I've explored that option and the formatting of the log
> file and the fact that EVERY query is logged is not what I'm after
> for this project.

You don't have to log every query.  You can set
log_min_duration_statement in postgresql.conf to log only the queries
that exceed a certain amount of time.

From the manual at
http://www.postgresql.org/docs/8.0/static/runtime-config.html:

log_min_duration_statement (integer)

    Sets a minimum statement execution time (in milliseconds) that
causes a statement to be logged. All SQL statements that run for the
time specified or longer will be logged with their duration. Setting
this to zero will print all queries and their durations. Minus-one
(the default) disables the feature. For example, if you set it to 250
then all SQL statements that run 250ms or longer will be logged.
Enabling this option can be useful in tracking down unoptimized
queries in your applications. Only superusers can change this setting.

George Essig

pgsql-performance by date:

Previous
From: Tom Lane
Date:
Subject: Re: investigating slow queries through pg_stat_activity
Next
From: Alex Stapleton
Date:
Subject: Re: autovacuum suggestions for 500,000,000+ row tables?