On Wednesday, April 15, 2015 at 12:09:41 PM UTC-7, Samuel Reh wrote:
>
> I have a problem where some of my queries run way too long. Obviously, the
> long term solution is to fix the slow queries, but for now I'd like to use
> some sort of timeout for when this happens. Currently I log in and run
> `select pg_terminate_backend(pid)`.
>
> I'm using the PG gem and the Threaded connection pool.
>
> Is there a way for Sequel to kill these connections (or better yet, put
> them in an idle state so they become available in the pool)? Or should I be
> using pg_bouncer for this kind of stuff?
>
PostgreSQL supports setting a statement timeout per connection, so you can
use an after_connect proc to set it for all connections that Sequel creates:
DB = Sequel.connect('postgres://...', :after_connect=>proc{|c|
c.execute('SET statement_timeout = 1000')}) # one second
Thanks,
Jeremy
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.