pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Oliver Jowett <oliver@opencloud.com>
To: Paul Lindner <lindner@inuus.com>
Cc: Gregory Stark <stark@enterprisedb.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Prepared Statements vs. pgbouncer
Date: Sun, 30 Sep 2007 11:50:10 +1300
Message-ID: <46FED6A2.8000209@opencloud.com> (raw)
In-Reply-To: <20070929144635.GK3140@inuus.com>
References: <20070929002513.GG3140@inuus.com>
	<87sl4xvmn2.fsf@oxford.xeocode.com>
	<20070929144635.GK3140@inuus.com>

Paul Lindner wrote:

> How do we fix this?  Short term?  Long term?

Build a connection pooling thing that does what you want it to do and 
implements the protocol *completely*.

For example the whole named statement problem goes away if the bit of 
software doing the pooling keeps track of

(a) which statements were prepared under which names on the "client" 
side connections (including query text & OIDs)
(b) which statements were prepared under which names on the "server" side
(c) relevant transaction and session state on both sides

Note that the names don't necessarily match up, the pool can merrily 
assign its own names on the server side.

Then it doesn't matter at all what names the clients use, it's 
irrelevant, they're still scoped within the connection they originated 
from as the protocol expects. Internally the pool then maps them to a 
new statement name on whichever real server connection it decides to 
push queries to. If the statement hasn't been prepared on that 
connection yet, that's fine, you just re-prepare it under a new name 
from the data you have stored.

And you get a "shared" prepared statement cache per server connection 
for free. You can also implement whatever logic you want for managing 
this cache, garbage collection and timing out idle statements, etc, as 
you see fit.

This is basically what I meant by fixing pgbouncer. No, it's not trivial 
to do, but there's no technical reason why it can't be done, you'll just 
need to throw development time at it.

You can also run this with a heterogenous client environment and not 
have to worry about clients following some particular subset of the 
protocol or cooperating over statement names and the like.

-O



view thread (48+ messages)  latest in thread

Message-ID: <46FED6A2.8000209@opencloud.com>
Permalink:  ../46FED6A2.8000209@opencloud.com/
Also on:    postgresql.org/message-id/46FED6A2.8000209@opencloud.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: oliver@opencloud.com, lindner@inuus.com, stark@enterprisedb.com
  Subject: Re: Prepared Statements vs. pgbouncer
  In-Reply-To: <46FED6A2.8000209@opencloud.com>
  References: <20070929002513.GG3140@inuus.com> <87sl4xvmn2.fsf@oxford.xeocode.com> <20070929144635.GK3140@inuus.com> <46FED6A2.8000209@opencloud.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