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.