Re: monitoring sql queries - Mailing list pgsql-general

From Tomas Vondra
Subject Re: monitoring sql queries
Date
Msg-id da0bcffc6a6868065b734c6d96887699.squirrel@sq.gransy.com
Whole thread Raw
In response to Re: monitoring sql queries  (hubert depesz lubaczewski <depesz@depesz.com>)
Responses Re: monitoring sql queries  (Scott Mead <scottm@openscg.com>)
Re: monitoring sql queries  ("J.V." <jvsrvcs@gmail.com>)
Re: monitoring sql queries  ("J.V." <jvsrvcs@gmail.com>)
List pgsql-general
On 17 Listopad 2011, 17:32, hubert depesz lubaczewski wrote:
> On Thu, Nov 17, 2011 at 09:29:11AM -0700, J.V. wrote:
>> I am in need of a tool or method to see each/every SQL query that
>> hits the PostgreSQL database.  By query I mean the query in SQL
>> syntax with all the parameters passed.
>>
>> What I want to do is:
>>     1) see the query
>>     2) Determine how long the query takes to execute
>>     3) Possibly log both of the above to a log file
>>
>> Is there any tool internal to PostgreSQL that would allow me to do this?
>>
>> I cannot monitor it from the code that is actually connecting &
>> sending the query.
>>
>> any help or pointers would be greatly appreciated.
>
> just enable logging of queries.

As depesz mentioned, there's a log_min_duration GUC, that allows you to
log queries that exceed some time interval. If you want to log all
queries, you may set this to 0 but it may easily fill your log with
garbage.

There are two contrib modules that might help you - pg_stat_statements and
auto_explain. The former one is probably more interesting in this case.

Tomas


pgsql-general by date:

Previous
From: hubert depesz lubaczewski
Date:
Subject: Re: monitoring sql queries
Next
From: Ivan Voras
Date:
Subject: Session variables and C functions