From c995bd126d143c427f35f39e960f72e41829d449 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Fri, 6 Feb 2009 18:18:54 +0000 Subject: [PATCH] Document ways to avoid libpq WSACleanup() overhead on Windows. Andrew Chernow --- doc/src/sgml/libpq.sgml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/doc/src/sgml/libpq.sgml b/doc/src/sgml/libpq.sgml index d5daec7e42..be2d9c304b 100644 --- a/doc/src/sgml/libpq.sgml +++ b/doc/src/sgml/libpq.sgml @@ -63,6 +63,21 @@ The PQstatus function should be called to check whether a connection was successfully made before queries are sent via the connection object. + + + + On Windows, there is a way to improve performance if a single + database connection is repeated started and shutdown. Internally, + libpq calls WSAStartup() and WSACleanup() for connection startup + and shutdown, respectively. WSAStartup() increments an internal + Windows library reference count which is decremented by WSACleanup(). + When the reference count is just one, calling WSACleanup() frees + all resources and all DLLs are unloaded. This is an expensive + operation. To avoid this, an application can manually call + WSAStartup() so resources will not be freed when the last database + connection is closed. + + -- 2.30.2