how to set postgresql command timeout in rails

后端 未结 4 847
梦谈多话
梦谈多话 2021-02-07 08:11

I\'m using heroku and heroku postgresql. How do I set db command timeout so that I get an exception when a sql command takes longer than 10 seconds?

4条回答
  •  自闭症患者
    2021-02-07 08:54

    I found a solution here: Ruby on Rails: How to set a database timeout in application configuration?

    Add

    ActiveRecord::Base.connection.execute('set statement_timeout to 10000')
    

    in the end of the environment.rb file.

    Does anyone see a better way?

提交回复
热议问题