WireSpot wrote:
> So it would eliminate the possibility of clashes, but do nothing for
> statement reuse.
Agreed.
> What would make it all the way better was if the database would do
> that last step for you as well: automatically recognize statements
> that do the same thing and return the already existing handle.
Sure. What I understand from the thread is that you're trying to
emulate in client code what would essentially be a server-side
plan-caching-and-reuse feature. Since it's refered to in the TODO list
(under the entry "Consider automatic caching of statements at various
levels"), I guess this feature doesn't exist in current versions.
Also contrary to prepared statements, maybe that cache would be shared
between connections, and that would be excellent, since it fits the
typical usage pattern of websites: a high-throughput of a small set of
low-latency queries, fired from pooled connections.
Not having the server reparsing and replanning over and over the same
queries can lead to very significant wins in latency, and it doesn't
have to involve any client-side specific code. What the client has to
do however is to use parameterized queries, otherwise the cache gets
polluted with non-reusable statements.
Best regards,
--
Daniel
PostgreSQL-powered mail user agent and storage:
http://www.manitou-mail.org