Re: Prepared statement already exists

From: "Daniel Verite" <daniel(at)manitou-mail(dot)org>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Prepared statement already exists
Date: 2008-11-21 16:35:54
Message-ID: 9f970a3a-6371-4ebf-933f-f1ad2fbdecb4@mm
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Richard Huxton 2008-11-21 16:35:55 Re: Res: converter pgplsql funcion
Previous Message Joshua D. Drake 2008-11-21 16:26:17 Re: Postgres mail list traffic over time