Efficiency of opening PostgreSQL database connections
<p>We have a PostgreSQL database to store our C++ application's data, and we use <a href="http://pqxx.org/development/libpqxx/" rel="nofollow">libpqxx</a> to connect to it.</p>

<p>Currently, we open a new <code>pqxx::connection</code> for each transaction we'd like to run. In deployment, we expect to execute at most probably about four or five dozen transactions per minute, and our application is going to be running 24x7x365.</p>

<p>According to the PostgreSQL <a href="http://www.postgresql.org/docs/9.4/static/tutorial-arch.html" rel="nofollow">architectural fundamentals</a>,</p>

<blockquote>
  <p>...[the PostgreSQL server process] starts ("forks") a new process for each connection.</p>
</blockquote>

<p>That sounds to me like our method of opening a new <code>pqxx::connection</code> for every transaction is really inefficient, since we are indirectly spawning a few dozen new processes every minute. Is this something that we should really be worried about?</p>

<p>I see <a href="https://wiki.postgresql.org/wiki/Number_Of_Database_Connections" rel="nofollow">here on the PostgreSQL wiki</a> that PostgreSQL does not, itself, maintain a pool of client connection processes, so it would seem that we do indeed need to worry about it. If so, is there a "proper" way to keep <code>pqxx::connection</code> objects around indefinitely so that a new process isn't being forked every time I need to connect to the database? Keep in mind that my application needs to run all day, every day, so it would be unacceptable for my TCP connections to drop after a long period of time.</p>