From: Oliver Jowett <oliver@opencloud.com>
To: Paul Lindner <lindner@inuus.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Prepared Statements vs. pgbouncer
Date: Sat, 29 Sep 2007 14:40:56 +1200
Message-ID: <46FDBB38.40003@opencloud.com> (raw)
In-Reply-To: <20070929021522.GH3140@inuus.com>
References: <20070929002513.GG3140@inuus.com>
<46FDA4F2.8080507@opencloud.com>
<20070929021522.GH3140@inuus.com>
Paul Lindner wrote:
> We're currently using Transaction pooling with pgbouncer. With
> prepareThreshhold set to 0, the only cases where server-side
> statements are used are with cursors. These occur inside transactions
> on our end.
The driver uses server-side statements for frequently-used internal
utility commands such as BEGIN too, and the lifetime of those statements
is essentially "the whole connection", not a particular transaction.
> It seems that the driver should immediately deallocate the server-side
> prepared statements it creates for cursors when it finishs fetching
> data for that cursor. This would be much better than waiting for the
> garbage collector to issue the deallocation.
We only rely on GC for statement deallocation if you don't explicitly
close your Statements. When you explicitly close them the server-side
statement is immediately enqueued on the reference queue, and will be
deallocated automatically when the next query is executed on the same
connection. If you just discard the statement, the enqueue is driven by GC.
There's no real reason for the driver to aggressively deallocate
statements merely because they were created so a portal could be used.
That sort of query is just as likely to be reused as any other.
>> Changing the JDBC driver to handle a "server" that doesn't follow the
>> documented server protocol seems a bit backwards. I think you're going
>> to have to teach pgbouncer a whole lot more about statements and portals
>> to get this one working.
>
> Well.. I only use pgBouncer to solve my particular issues.
And now you have two problems ;-)
> Digging a little deeper I see that Postgres 8.3 will have DEALLOCATE
> ALL and DISCARD ALL commands that can be used in pgbouncers health check.
That's going to break things even further since now the driver will have
statements that it thinks the server has prepared that will fail when
used because pgbouncer has decided it should go and deallocate them all!
-O
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
Subject: Re: Prepared Statements vs. pgbouncer
In-Reply-To: <46FDBB38.40003@opencloud.com>
References: <20070929002513.GG3140@inuus.com> <46FDA4F2.8080507@opencloud.com> <20070929021522.GH3140@inuus.com> <46FDBB38.40003@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