HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlModerate

Is it possible to configure PostgreSQL to automatically close idle connections?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
postgresqlcloseautomaticallyconnectionspossibleidleconfigure

Problem

Clients connect to our PostgreSQL 8.3 database but leave the connections opened. Is it possible to configure PostgreSQL to close those connections after a certain amount of inactivity?

Solution

Finally, I have a solution.
I'll use the tool PgBouncer with its parameter server_idle_timeout.

Another approach would consist in using some cron-like tool running a query periodically to find idle connections.

Once those idle connections are found, a simple call to pg_terminate_backend will close them.

See an in depth description of this approach in the anwser of the following question:

How to close idle connections in PostgreSQL automatically?

Context

StackExchange Database Administrators Q#24193, answer score: 10

Revisions (0)

No revisions yet.