Can I log query execution time in PostgreSQL 8.4?

前端 未结 3 1508
刺人心
刺人心 2020-12-31 08:32

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           


        
3条回答
  •  难免孤独
    2020-12-31 09:10

    I believe OP was actually asking for execution duration, not the timestamp.

    To include the duration in the log output, open pgsql//data/postgresql.conf, 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.

提交回复
热议问题