| From: | Erik Wienhold <ewie(at)ewie(dot)name> |
|---|---|
| To: | Rajesh Kumar <rajeshkumar(dot)dba09(at)gmail(dot)com> |
| Cc: | Pgsql-admin <pgsql-admin(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: Handling idle connections |
| Date: | 2023-09-24 13:29:34 |
| Message-ID: | kd2wgxkkdydj55fmu5hrewi2xtdb47t3l4kzv7xryd2b7rpxmk@zdqaigztd5pa |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-admin |
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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Zhaoxun Yan | 2023-09-24 14:23:28 | Re: Corruption issue |
| Previous Message | Scott Ribe | 2023-09-24 13:19:44 | Re: Handling idle connections |