pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Paul Lindner <lindner@inuus.com>
To: Till Toenges <tt@kyon.de>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Prepared Statements vs. pgbouncer
Date: Mon, 1 Oct 2007 13:49:17 -0700
Message-ID: <20071001204917.GP3140@inuus.com> (raw)
In-Reply-To: <470125E2.9060505@kyon.de>
References: <20070929002513.GG3140@inuus.com>
	<87sl4xvmn2.fsf@oxford.xeocode.com>
	<20070929144635.GK3140@inuus.com>
	<46FED6A2.8000209@opencloud.com>
	<20070930070725.GL3140@inuus.com>
	<470125E2.9060505@kyon.de>

On Mon, Oct 01, 2007 at 06:52:50PM +0200, Till Toenges wrote:
> Paul Lindner wrote:
> >1) Use hashing to choose a prepared statement name
> >
> >   If we take the hash of the prepared statement text and prefix with
> >   S_ we can be assured of using the same unique prepared statement
> >   name across all application servers.
> >
> >   (And yes, I know that hashes are not perfect and collisions can
> >    occur.  Highly unlikely if we choose a good hash)
> 
> This sounds like a bad idea on many levels. Don't do it. Actually, i 
> think the driver is ok and the real problem is pgbouncer.

Actually the problem is that Postgres is process/session oriented in a
multithreaded event-based world.

> I have another solution to your problem:
> 
> You said that there are 100s of Servers, i assume that there is some 
> money behind that. Talk to the pgbouncer developers. Ask them to analyze 
> your problem and what it would cost to fix it. Ask them what it would 
> cost to make pgbouncer fully compliant, because it's probably not the 
> only feature you will miss. Figure out if this is cheaper than replacing 
> / upgrading your hardware with something powerful enough to handle the 
> load without pgbouncer. Pick the cheaper solution. Done.

The problem is that the described solution puts way too much moving
parts inside of something that should be very simple.  You'd have to
recreate most of Postgresql's parsing and grammar inside of Pgbouncer
and change it from something simple into a full-featured proxy.

In my opinion the _correct_ way to fix the problem of too many bloated
idle backends is to incorporate libevent into Postgres and radically
rethink of ways to maintain cache/session coherence.

> "Fixing" the jdbc driver is probably not a stable long term solution, 
> even if it helps with your most immediate problem.

Fixing the JDBC driver is the simplest and cheapest alternative.  So I
am following your advice and picking the cheaper solution :)

-- 
Paul Lindner        ||||| | | | |  |  |  |   |   |
lindner@inuus.com

view thread (48+ messages)  latest in thread

Message-ID: <20071001204917.GP3140@inuus.com>
Permalink:  ../20071001204917.GP3140@inuus.com/
Also on:    postgresql.org/message-id/20071001204917.GP3140@inuus.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: lindner@inuus.com, tt@kyon.de
  Subject: Re: Prepared Statements vs. pgbouncer
  In-Reply-To: <20071001204917.GP3140@inuus.com>
  References: <20070929002513.GG3140@inuus.com> <87sl4xvmn2.fsf@oxford.xeocode.com> <20070929144635.GK3140@inuus.com> <46FED6A2.8000209@opencloud.com> <20070930070725.GL3140@inuus.com> <470125E2.9060505@kyon.de> <20071001204917.GP3140@inuus.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox