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

From Lukas Kahwe Smith
Subject Re: Prepared statements considered harmful
Date
Msg-id 44F7E0A0.3040506@pooteeweet.org
Whole thread Raw
In response to Re: Prepared statements considered harmful  (Martijn van Oosterhout <kleptog@svana.org>)
Responses Re: Prepared statements considered harmful  (Martijn van Oosterhout <kleptog@svana.org>)
List pgsql-hackers
Martijn van Oosterhout wrote:
> On Thu, Aug 31, 2006 at 07:04:07PM -0400, Gregory Stark wrote:
>> The server has to prepare the query sometime. The v3 protocol just gives you
>> control over when that happens, but it doesn't force you to do it at any
>> particular time.
> 
> Not really. All named prepares are planned straight away, all unnamed
> ones are planned at bind time. Therefore you cannot have more than one
> parsed-but-not-planned prepared query at a time. In a connection pool
> scenario there's no way to share such plans since you can't tell which
> query has been prepared. That's not forcing, but it's an asymmetry we
> could do with out.

AFAIK since Oracle 9i planning is always deferred until the first 
execution. This way they hope to get a better plan, which would 
obviously not be possible if the selectivity varies greatly.

So are the plans generated without taking any bound values into account 
more stable in performance (albeit at times slower than what would have 
been produced if the value would have been known)?

Either way mixing the question of when to prepare the plan with the 
prepared statement being named or unnamed seems unexpected.

regards,
Lukas


pgsql-hackers by date:

Previous
From: Martijn van Oosterhout
Date:
Subject: Re: Prepared statements considered harmful
Next
From: "Zeugswetter Andreas DCP SD"
Date:
Subject: Re: Prepared statements considered harmful