Re: PostgreSQL 9.0 x64 bit pgbench TPC very low question?

From: Kenneth Marshall <ktm(at)rice(dot)edu>
To: tuanhoanganh <hatuan05(at)gmail(dot)com>
Cc: Gurjeet Singh <singh(dot)gurjeet(at)gmail(dot)com>, Magnus Hagander <magnus(at)hagander(dot)net>, pgsql-performance(at)postgresql(dot)org
Subject: Re: PostgreSQL 9.0 x64 bit pgbench TPC very low question?
Date: 2010-12-23 14:46:28
Message-ID: 20101223144628.GL10252@aart.is.rice.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Thu, Dec 23, 2010 at 09:20:59PM +0700, tuanhoanganh wrote:
> Could you show me what parameter of pgbouncer.ini can do that. I read
> pgbouncer and can not make pgbouncer open and keep 200 connect to postgres
> (Sorry for my English)
>
> Thanks you very much.
>
> Tuan Hoang ANh
>

You need to use session pooling for that to work. From the man page:

In order not to compromise transaction semantics for connection
pooling, pgbouncer supports several types of pooling when
rotating connections:

Session pooling
Most polite method. When client connects, a server connection
will be assigned to it for the whole duration the client
stays connected. When the client disconnects, the server
connection will be put back into the pool. This is the
default method.

Transaction pooling
A server connection is assigned to client only during a
transaction. When PgBouncer notices that transaction is over,
the server connection will be put back into the pool.

Statement pooling
Most aggressive method. The server connection will be put back
into pool immediately after a query completes. Multi-statement
transactions are disallowed in this mode as they would break.

The fact that pgbouncer will not keep 200 connections open to
the database means that you do not have enough work to actually
keep 200 permanent connections busy. It is much more efficient
to use transaction pooling. You typically want the number of
persistent database connections to be a small multiple of the
number of CPUs (cores) on your system. Then set pgbouncer to
allow as many client connections as you need. This will give
you the best throughput and pgbouncer can setup and tear down
the connections to your clients much, much faster than making
a full connection to the PostgreSQL database.

Regards,
Ken

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message tuanhoanganh 2010-12-23 15:20:19 Re: PostgreSQL 9.0 x64 bit pgbench TPC very low question?
Previous Message Kevin Grittner 2010-12-23 14:37:48 Re: PostgreSQL 9.0 x64 bit pgbench TPC very low question?