Re: Prepared statements considered harmful

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Gregory Stark <stark(at)enterprisedb(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Prepared statements considered harmful
Date: 2006-08-31 18:01:09
Message-ID: 200608312001.10245.peter_e@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Gregory Stark wrote:
> Then you would be going very much against the user's expectations.
>
> Driver interfaces expose very clearly to the user an explicit
> interface to prepare and execute a query separately. What your
> proposing is to go behind the user's back and do what he's gone out
> of his way to tell you not to do. You can always choose to prepare
> your queries immediately before use. Most drivers even supply an
> interface to do so in a single step for convenience.

Let's verify that. JDBC and PL/pgSQL have been mentioned.

The JDBC documentation merely contains statements of the sort "A SQL
statement with or without IN parameters can be pre-compiled and stored
in a PreparedStatement object. This object can then be used to
efficiently execute this statement multiple times." There is
absolutely no indication that the execution plan of the statement is
computed at the time of preparation. In fact, it doesn't say
what "pre-compiled" means at all.

For PL/pgSQL, you simply write a query and all the preparing action
happens implicitly. There is nothing explicit about that interface.

So if users have certain expectations here, they're just making them up.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Martijn van Oosterhout 2006-08-31 18:08:40 Re: Prepared statements considered harmful
Previous Message Tom Lane 2006-08-31 17:50:50 Re: [COMMITTERS] pgsql: Second try committing the path changes.