Re: Prepared statement already exists - Mailing list pgsql-general

From Daniel Verite
Subject Re: Prepared statement already exists
Date
Msg-id 9f970a3a-6371-4ebf-933f-f1ad2fbdecb4@mm
Whole thread Raw
In response to Re: Prepared statement already exists  (WireSpot <wirespot@gmail.com>)
Responses Re: Prepared statement already exists  (Alvaro Herrera <alvherre@commandprompt.com>)
List 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

pgsql-general by date:

Previous
From: Richard Huxton
Date:
Subject: Re: Res: converter pgplsql funcion
Next
From: Alvaro Herrera
Date:
Subject: Re: Prepared statement already exists