Re: Prepared statements considered harmful - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Prepared statements considered harmful
Date
Msg-id 8619.1157040291@sss.pgh.pa.us
Whole thread Raw
In response to Re: Prepared statements considered harmful  (AgentM <agentm@themactionfaction.com>)
Responses Re: Prepared statements considered harmful
Re: Prepared statements considered harmful
List pgsql-hackers
AgentM <agentm@themactionfaction.com> writes:
> On Aug 31, 2006, at 11:18 , mark@mark.mielke.cc wrote:
>> I'm attempting to understand why prepared statements would be used for
>> long enough for tables to change to a point that a given plan will
>> change from 'optimal' to 'disastrous'.

> Scenario: A web application maintains a pool of connections to the  
> database. If the connections have to be regularly restarted due to a  
> postgres implementation detail (stale plans), then that is a database  
> deficiency.

The two major complaints that I've seen are

* plpgsql's prepared plans don't work at all for scenarios involving
temp tables that are created and dropped in each use of the function.
Then, the plan needs to be regenerated on every successive call.
Right now we tell people they have to use EXECUTE, which is painful
and gives up unnecessary amounts of performance (because it might
well be useful to cache a plan for the lifespan of the table).

* for parameterized queries, a generic plan gives up too much
performance compared to one generated for specific constant parameter
values.

Neither of these problems have anything to do with statistics getting
stale.
        regards, tom lane


pgsql-hackers by date:

Previous
From: mark@mark.mielke.cc
Date:
Subject: Re: Prepared statements considered harmful
Next
From: Tom Lane
Date:
Subject: Re: Prepared statements considered harmful