[Proposal] Postgrex - allow configuring statement_timeout

9 views
Skip to first unread message

JanPaul Bergeson

unread,
Apr 18, 2024, 1:07:09 PMApr 18
to elixir-ecto
Hi,

I've been told by my company's DBA that we should look into setting `statement_timeout` on our Postgres connections. In a nutshell, this is a configuration option that will time out any individual statement that takes longer than this value (in ms). It seems like we can set this with a simple statement like this:

set statement_timeout=600000;

I'm not sure where this statement would go... Any suggestions there? I guess we should just run it with `execute` soon after the database connection is established, but I'm not sure if there's some sort of hook to run code like this upon database connection.

(The other option is to just set it for the entire Postgres DB -- however, our DBA advised that this setting should be handled at the app end for effective connection handling.)

Does this seem like something that would be useful to go into Postgrex itself? There are already options such as timeout, connect_timeout, etc. so to me it would make sense if `statement_timeout` was added as another configurable option.

José Valim

unread,
Apr 18, 2024, 1:41:02 PMApr 18
to elixi...@googlegroups.com
You can use the after_connect callback to run such commands to set everything up.

--
You received this message because you are subscribed to the Google Groups "elixir-ecto" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-ecto...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-ecto/d47e0499-fbd8-436b-b414-7284580af55en%40googlegroups.com.

José Valim

unread,
Apr 18, 2024, 1:42:11 PMApr 18
to elixi...@googlegroups.com
And hi! 👋 
Reply all
Reply to author
Forward
0 new messages