I want to log each query execution time which is run in a day.
For example like this,
2012-10-01 13:23:38 STATEMENT: SELECT * FROM pg_stat_database
I believe OP was actually asking for execution duration, not the timestamp.
To include the duration in the log output, open pgsql/
, find the line that reads
#log_duration = off
and change it to
log_duration = on
If you can't find the given parameter, just add it in a new line in the file.
After saving the changes, restart the postgresql service, or just invoke
pg_ctl reload -D
e.g.
pg_ctl reload -D /var/lib/pgsql/9.2/data/
to reload the configuration.