I would like to set some db session variables specific to my application on the database connection that rails uses. They can be set by issuing an SQL command like "SET statement_timeout = 1000" once - it will be in effect for every subsequent SQL statement that uses this connection.
So I tried to put the following into an initializer:
ActiveRecord::Base.connection.execute("SET statement_timeout = 1000")
but this does not have the desired effect - it is not set for all connections. I assume this has to do with the connection pool rails uses - the code above just sets it for a single one.
The PostgreSQLAdapter issues some SET statements itself for each new connection - is there a good way to add your own configuration statements, either specific to the PostgreSQLAdapter or in a general way?
Til