Re: Prepared statements considered harmful

From: Lukas Kahwe Smith <smith(at)pooteeweet(dot)org>
To: Martijn van Oosterhout <kleptog(at)svana(dot)org>
Subject: Re: Prepared statements considered harmful
Date: 2006-09-01 07:26:24
Message-ID: 44F7E0A0.3040506@pooteeweet.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Zeugswetter Andreas DCP SD 2006-09-01 07:38:41 Re: Prepared statements considered harmful
Previous Message Anton de Wet 2006-09-01 07:20:38 Re: Thought provoking piece on NetBSD