Search Postgresql Archives

Re: Pgbouncer help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks Jeff,

As I understand from your point, instead of connecting Postgresql port, try to use PgBouncer port. 

I am using libpq library functions connect postgreql and code changes would be like this.

Previous code :

sprintf(conninfo, "user=%s password=%s dbname=%s hostaddr=%s port=%d", PG_USER, PG_PASS, PG_DB, PG_HOST, PG_PORT);
conn = PQconnectdb(conninfo);

new code:

sprintf(conninfo, "user=%s password=%s dbname=%s hostaddr=%s port=%d", PG_USER, PG_PASS, PG_DB, PG_HOST, PG_BOUNCER_PORT);
conn = PQconnectdb(conninfo);


-----Original Message-----
From: Jeff Janes [mailto:jeff.janes@xxxxxxxxx] 
Sent: Tuesday, August 27, 2013 11:10 PM
To: Yelai, Ramkumar IN BLR STS
Cc: pgsql-general@xxxxxxxxxxxxxx
Subject: Re:  Pgbouncer help

On Tue, Aug 27, 2013 at 1:34 AM, Yelai, Ramkumar IN BLR STS <ramkumar.yelai@xxxxxxxxxxx> 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.

If you want all connections to the database to go through pgbouncer, you can move the real server to a different port, and then start up pgbouncer on that vacated port.  In this case, the clients do not need to make any changes at all to their configuration.

If you want to keep the real server on the same port as it currently is and to use a special port to go through pgbouncer, then you need to change the clients to use that new port number.  You do this the same way you would change the client to use a different port if that different port were a regular postgresql server.

Cheers,

Jeff


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general





[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux