Postgresql – How to determine the current “idle timeout” value for PostgreSQL

postgresql

Sigh. I've been searching forever for this and, as usual, find nothing.

I'm not talking about the "connection timeout" for how long it waits before giving up when trying to connect to the database. I'm talking about how long a database connection can be "idle" without any queries being executed (and no pg_pings) before it's considered abandoned and force-closed.

Which setting controls this, and how do I retrieve it?

Best Answer

Before 9.6, no such timeout exists in PostgreSQL. Thereafter, it only exists if you are idle in the middle of a transaction.

show idle_in_transaction_session_timeout;

Note however that any router, gateway, or firewall between you and the server can nuke your connection at any time it chooses. TPC keepalives may or may not dissuade them. PostgreSQL can't offer much insight into what your networking equipment does.