2

I would like to test a timeout handler for sql query longer than 5 seconds:

module ActiveRecord
  module ConnectionAdapters
    class PostgreSQLAdapter

      def configure_connection_with_statement_timeout
        configure_connection_without_statement_timeout
        ActiveRecord::Base.logger.silence do
          execute('SET statement_timeout = 5000')
        end
      end
      alias_method_chain :configure_connection, :statement_timeout

    end
  end
end

But I don't know how to make such a slow sql query with Active Record.

Juanito Fatas
  • 9,419
  • 9
  • 46
  • 70

1 Answers1

6

Possible duplicate of: Delay or Wait-For Statement


pg_sleep seems to do that (10 seconds sleep):

SELECT pg_sleep(10); 

See also: http://blog.endpoint.com/2012/11/how-to-make-postgresql-query-slow.html

Community
  • 1
  • 1
MrYoshiji
  • 54,334
  • 13
  • 124
  • 117