Re: monitoring sql queries

From: Scott Mead <scottm(at)openscg(dot)com>
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 21:52:42
Message-ID: CAKq0gvKN_T-FLfBC3j4pAsaO_fK_Bcf_8t1G=J5JHN1msBp61A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Nov 17, 2011 at 4:32 PM, J.V. <jvsrvcs(at)gmail(dot)com> wrote:

> How is this accomplished?
>
> Is it possible to log queries to a table with additional information?
>
> 1) num rows returned (if a select)
>
This isn't logged

> 2) time to complete the query
>
This is logged

> 3) other info?
>
> Take a look at the log_line_prefix parameter

> How is enabling this actually done?
>
>
> You enable this by using a GUC (global unified config) variable in the
postgresql.conf file called log_min_duration_statement.

--Scott

> On 11/17/2011 9:32 AM, 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.
>>
>> Best regards,
>>
>> depesz
>>
>>
> --
> 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<http://www.postgresql.org/mailpref/pgsql-general>
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tomas Vondra 2011-11-17 23:03:12 Re: monitoring sql queries
Previous Message Bill Moran 2011-11-17 21:46:21 Re: monitoring sql queries