Re: Time Stamp

From: Scott Marlowe <smarlowe(at)g2switchworks(dot)com>
To: Hrishikesh Deshmukh <hdeshmuk(at)gmail(dot)com>
Cc: Postgresql-General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Time Stamp
Date: 2005-03-21 15:50:32
Message-ID: 1111420232.26897.45.camel@state.g2switchworks.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, 2005-03-21 at 09:29, Hrishikesh Deshmukh wrote:
> Hi All,
>
> I want to get a "timestamp" of the queries that i run!
> Is there a builtin command to do this/ does one need to write a
> function/stored procedure!
> Any pointers will help.

This is actually a pretty wide open question. Do you want to know how
long it took to run the query, or when it ran? Do you want a list of
all the times it ran, or just the latest? Are you basically auditing db
access, or just checking to see how well it's running?

If you're just monitoring for performance et. al. then look at the
logging setting of log_min_duration_statement which tells the backend
how long a query needs to take to be logged. you use the other settings
in the postgresql.conf file to force it to log every statement and its
duration.

Otherwise, you can use a trigger to force it to store the timestamp of
every row inserted, if that's what you need. I think there's a basic
example in the online docs for server programming. There are also many
examples posted to this list, so you could search the archives.

In response to

  • Time Stamp at 2005-03-21 15:29:51 from Hrishikesh Deshmukh

Browse pgsql-general by date

  From Date Subject
Next Message Richard Huxton 2005-03-21 15:57:38 Re: Time Stamp
Previous Message Sean Davis 2005-03-21 15:46:00 Re: pl/perl problem