Set a Statement Timeout for PostgreSQL Queries in Rails
Long running queries can tie up database connections, eventually bogging down your app and causing it to come to a grinding halt. Thankfully you can leverage statement_timeout to cause long running queries to raise an error.