Re: monitoring sql queries

From: "Tomas Vondra" <tv(at)fuzzy(dot)cz>
To: "J(dot)V(dot)" <jvsrvcs(at)gmail(dot)com>
Cc: "PostgreSQL" <pgsql-general(at)postgresql(dot)org>
Subject: Re: monitoring sql queries
Date: 2011-11-17 23:03:12
Message-ID: 99d969a3a72cf6852187299599afde2e.squirrel@sq.gransy.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 17 Listopad 2011, 22:34, J.V. wrote:
> What is a GUC and how do I use it?

It just means there's a config option log_min_duration_statement that you
can set in postgresql.conf. Set it e.g. to 100, reload the configuration
(e.g. by restarting the server or sending HUP signal to the process) and
all queries exceeding 100ms will be logged.

Tomas

>
> On 11/17/2011 9:46 AM, Tomas Vondra wrote:
>> 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
>>
>>
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message deepak 2011-11-17 23:41:22 Authentication configuration for local connections on Windows
Previous Message Scott Mead 2011-11-17 21:52:42 Re: monitoring sql queries