Re: Pgbouncer help

From: "Yelai, Ramkumar IN BLR STS" <ramkumar(dot)yelai(at)siemens(dot)com>
To: "scrawford(at)pinpointresearch(dot)com" <scrawford(at)pinpointresearch(dot)com>, "jeff(dot)janes(at)gmail(dot)com" <jeff(dot)janes(at)gmail(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Pgbouncer help
Date: 2013-08-28 12:56:07
Message-ID: 13D0F6C9B3073A4999E61CAAD61AE7ECCEAD9E2E98@INBLRK77M2MSX.in002.siemens.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thanks for your great inputs.

Let me see, how to handle these situations in our project.

Regards,
Ramkumar

-----Original Message-----
From: Steve Crawford [mailto:scrawford(at)pinpointresearch(dot)com]
Sent: Wednesday, August 28, 2013 1:09 AM
To: Jeff Janes
Cc: Yelai, Ramkumar IN BLR STS; pgsql-general(at)postgresql(dot)org
Subject: Re: [GENERAL] Pgbouncer help

On 08/27/2013 10:40 AM, Jeff Janes wrote:
> On Tue, Aug 27, 2013 at 1:34 AM, Yelai, Ramkumar IN BLR STS
> <ramkumar(dot)yelai(at)siemens(dot)com> wrote:
>> HI
>>
>>
>>
>> In our current project, we are opening several postgresql connection.
>> Few connections are frequently used and few are occasionally used.
>> Hence we plan to adapt connection pool method to avoid more
>> connection to open. We plan to use "Pgbouncer". Most of the
>> pgbouncer example shows how to configure, but they are not explaining how to use in C++.
>>
>>
>>
>> Please provide me a example, how to use it in C++.
> pgbouncer is designed to look (to the client) just like a normal
> postgresql server....
However...

Since clients are reusing previously accessed server sessions, be sure to consider the implication of the different pool types and reset options.

For example, if you have multi-statement transactions you cannot, of course, use statement-level pooling since the server connection is released after the statement.

And if you set any runtime parameters (set time zone to..., set statement timeout..., etc.) then you will probably need to use session-level pooling and you will need to set server_reset_query appropriately otherwise you risk ending up either having parameters set to values you did not expect by a previously connected client or having parameters you set "disappear" when your next statement is assigned to a different server connection.

A similar issue exists if you use temporary tables as you need to be sure to stick with the same server connection while your processing needs the temporary table and you need to clean it up when you release the connection so it doesn't use extra resources and doesn't interfere with statements issued a subsequent client.

For more, see the following if you haven't read them already:
http://pgbouncer.projects.pgfoundry.org/doc/config.html
http://wiki.postgresql.org/wiki/PgBouncer

Cheers,
Steve

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Moshe Jacobson 2013-08-28 14:53:33 Re: pg_extension_config_dump() with a sequence
Previous Message Shaun Thomas 2013-08-28 12:53:58 Re: Problems with adding IP to pg_hba.conf