From b1be3074ac719ce8073fba35d4c8b52fb4ddd0c3 Mon Sep 17 00:00:00 2001 From: Fujii Masao Date: Fri, 2 Apr 2021 19:45:42 +0900 Subject: postgres_fdw: Add option to control whether to keep connections open. This commit adds a new option keep_connections that controls whether postgres_fdw keeps the connections to the foreign server open so that the subsequent queries can re-use them. This option can only be specified for a foreign server. The default is on. If set to off, all connections to the foreign server will be discarded at the end of transaction. Closed connections will be re-established when they are necessary by future queries using a foreign table. This option is useful, for example, when users want to prevent the connections from eating up the foreign servers connections capacity. Author: Bharath Rupireddy Reviewed-by: Alexey Kondratov, Vignesh C, Fujii Masao Discussion: https://postgr.es/m/CALj2ACVvrp5=AVp2PupEm+nAC8S4buqR3fJMmaCoc7ftT0aD2A@mail.gmail.com --- doc/src/sgml/postgres-fdw.sgml | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/postgres-fdw.sgml b/doc/src/sgml/postgres-fdw.sgml index c21e9be209b..a7c695b000f 100644 --- a/doc/src/sgml/postgres-fdw.sgml +++ b/doc/src/sgml/postgres-fdw.sgml @@ -518,6 +518,33 @@ OPTIONS (ADD password_required 'false'); + + + Connection Management Options + + + By default all the open connections that postgres_fdw + established to the foreign servers are kept in local session for re-use. + + + + + + keep_connections + + + This option controls whether postgres_fdw keeps + the connections to the foreign server open so that the subsequent + queries can re-use them. It can only be specified for a foreign server. + The default is on. If set to off, + all connections to this foreign server will be discarded at the end of + transaction. + + + + + + @@ -605,8 +632,10 @@ postgres=# SELECT postgres_fdw_disconnect_all(); postgres_fdw establishes a connection to a foreign server during the first query that uses a foreign table - associated with the foreign server. This connection is kept and - re-used for subsequent queries in the same session. However, if + associated with the foreign server. By default this connection + is kept and re-used for subsequent queries in the same session. + This behavior can be controlled using + keep_connections option for a foreign server. If multiple user identities (user mappings) are used to access the foreign server, a connection is established for each user mapping. @@ -622,8 +651,10 @@ postgres=# SELECT postgres_fdw_disconnect_all(); Once a connection to a foreign server has been established, - it's usually kept until the local or corresponding remote + it's by default kept until the local or corresponding remote session exits. To disconnect a connection explicitly, + keep_connections option for a foreign server + may be disabled, or postgres_fdw_disconnect and postgres_fdw_disconnect_all functions may be used. For example, these are useful to close -- cgit v1.2.3