How to activate slow queries logs in postgresql?

https://access.redhat.com/solutions/69314

 SOLUTION UNVERIFIED - 已更新 2013年三月13日22:09 - 

English 

环境

  • Red Hat Enterprise Linux 6
  • postgresql-server

问题

  • How to activate slow queries logs in postgresql?

决议

You could set this in postgresql.conf, To find the postgresql.conf you could use the find command like this:

Raw

    # find / -name postgresql.conf

Now, in the postgresql.conf file you should look for the line:

Raw

    #log_min_duration_statement = -1

and replace it with:

Raw

    log_min_duration_statement = 500

This will log any querie that takes more than 500ms (miliseconds) to be done. You could adjust this to the value that you may considerer correct.

After that, save the file and reload the PostgreSQL configuration:

Raw

    # service postgresql reload

Go to the directory where the logs of PostgreSQL are (comonly located in /var/lib/pgsql/data/pg_lo) and look for the lasted log file created.

Below, you will find an example of a query that took more than 500ms:

Raw

    2011-09-29 11:27:39 BRT LOG: duration: 2051.457 ms execute pdo_stmt_000000b4: select * from backuplog WHERE message LIKE '%xyz%'
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值