Re: libpq WSACleanup is not needed - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: libpq WSACleanup is not needed
Date
Msg-id 200902061819.n16IJWM08763@momjian.us
Whole thread Raw
In response to Re: libpq WSACleanup is not needed  (Andrew Chernow <ac@esilo.com>)
Responses Re: libpq WSACleanup is not needed
List pgsql-hackers
Andrew Chernow wrote:
> Andrew Chernow wrote:
> > Tom Lane wrote:
> >> Andrew Chernow <ac@esilo.com> writes:
> >>> I can try.  Where should this be documented?  ISTM that the best
> >>> place is at the top of "30.1 Database Connection Control Functions",
> >>> since the issue pertains to any connect/disconnect function.  Does
> >>> that sound correct?  Should it be a warning or just regular text?
> >>
> >> Minor platform-specific performance nits are not that important.  Think
> >> "footnote", not "warning at the top of the page".
> >>
> > Its a footnote at the end of the first paragraph in 30.1.
>
> Fixed a few things.

I have applied a modified version of this documentation patch, attached.
Thanks.

--
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +
Index: doc/src/sgml/libpq.sgml
===================================================================
RCS file: /cvsroot/pgsql/doc/src/sgml/libpq.sgml,v
retrieving revision 1.275
diff -c -c -r1.275 libpq.sgml
*** doc/src/sgml/libpq.sgml    10 Jan 2009 20:14:30 -0000    1.275
--- doc/src/sgml/libpq.sgml    6 Feb 2009 18:17:55 -0000
***************
*** 63,68 ****
--- 63,83 ----
     The <function>PQstatus</> function should be called to check
     whether a connection was successfully made before queries are sent
     via the connection object.
+
+    <note>
+     <para>
+      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.
+     </para>
+    </note>

     <variablelist>
      <varlistentry>

pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: new GUC var: autovacuum_process_all_tables
Next
From: Andrew Chernow
Date:
Subject: Re: libpq WSACleanup is not needed