Re: statement caching proof of concept - Mailing list pgsql-jdbc

From till toenges
Subject Re: statement caching proof of concept
Date
Msg-id 44972EB9.8060508@kyon.de
Whole thread Raw
In response to Re: statement caching proof of concept  (till toenges <tt@kyon.de>)
List pgsql-jdbc
till toenges wrote:
> The current situation allows to use a prepared statement from several
> threads at once, or more than once before reading the result in a single
> thread. There is no way to get all the results back reliably in this
> case. Since the JDBC specifications don't demand anything more (afaik),
> solution 1 seems ok.

Oversight on my part: If the caching is automatic, an application that
originally used several prepared statements with the same sql and now
gets only one from the cache would very probably misbehave. Therefore
"just allowing it" is not an option.

In fact, i have no precise idea how a statement would know that it is
ready for reuse. An application could keep a reference to the statement
and run it again and again. WeakReferences and ReferenceQueues could be
used. Always interesting to play with the garbage collector ;-)

Maybe the postgres api has a way to identify individual calls and then
Mark Lewis idea of just caching the handle and creating individual
prepared statement objects upon use is the right way to go.


Till

pgsql-jdbc by date:

Previous
From: till toenges
Date:
Subject: Re: statement caching proof of concept
Next
From: Oliver Jowett
Date:
Subject: Re: statement caching proof of concept