Re: Handling idle connections

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2023-09-24 12:57 +0530, Rajesh Kumar wrote:
> What is the best way to handle idle connections other than manually killing
> idle connections if I do not have connection pooler.

Couple of options depending on your Postgres version and whether you
only care about idle connections with open transactions:

* set idle_in_transaction_session_timeout [1] for idle connections with
  an open transaction

* set idle_session_timeout [2] (requires pg14+) for idle connections
  without an open transaction

* use a cron job that checks connections in view pg_stat_activity and
  terminates them as necessary

[1] https://www.cybertec-postgresql.com/en/idle_in_transaction_session_timeout-terminating-idle-transactions-in-postgresql/
[2] https://www.postgresql.org/docs/current/runtime-config-client.html#GUC-IDLE-SESSION-TIMEOUT

-- 
Erik





[Index of Archives]     [Postgresql Home]     [Postgresql General]     [Postgresql Performance]     [Postgresql PHP]     [Postgresql Jobs]     [PHP Users]     [PHP Databases]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Yosemite Forum]

  Powered by Linux