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?
I don't know ruby, but in PostgreSQL you can simply run this:
SET statement_timeout = '10s'
and afterwards, all queries in this connection (session) will have strict limit on runtime.
You can also change it in postgresql.conf as global default, or even make it default in given database or for given user like:
ALTER DATABASE web SET statement_timeout = '10s';
ALTER USER bad_user SET statement_timeout = '10s';