Re: Avoiding bad prepared-statement plans. - Mailing list pgsql-hackers

From Greg Stark
Subject Re: Avoiding bad prepared-statement plans.
Date
Msg-id 407d949e1002160628v14966092iea1bf26e34039344@mail.gmail.com
Whole thread Raw
In response to Re: Avoiding bad prepared-statement plans.  (Bruce Momjian <bruce@momjian.us>)
Responses Re: Avoiding bad prepared-statement plans.
Re: Avoiding bad prepared-statement plans.
List pgsql-hackers
On Mon, Feb 15, 2010 at 7:11 PM, Bruce Momjian <bruce@momjian.us> wrote:
> 1. Why do we only do bind-level planning for anonymous wire-level queries?
>
> 2. I realize we did anonymous-only because that was the only way we had
> in the protocol to _signal_ bind-time planning, but didn't we think of
> this when we were implementing the wire-level protocol?

Is there any other difference between anonymous and non-anonymous
queries? If this is the only major difference do we need to separate
them? Is there any particular reason a driver would need two prepared
queries if they're both just going to be planned at execution time?

Incidentally, can you have two active anonymous portals at the same time?


> 4. Why don't we just always do planning at first bind time?  When is
> that worse than using generic values?
>
> 6. When do our generic columns costs significantly worse than having
> specific constants?  I assume unique columns are fine with generic
> constants.

Well using parameters will always have a better chance of producing a
better plan but that's not the only factor people consider important.
For a lot of users *predictability* is more important than absolute
performance. If my web server could run 10% faster that might be nice
but if it's capable of keeping up at its current speed it's not
terribly important. But if it means it crashes once a day because some
particular combination of parameters causes a bad plan to be used for
a specific user that's a bad trade-off.

--
greg


pgsql-hackers by date:

Previous
From: Greg Stark
Date:
Subject: Re: Avoiding bad prepared-statement plans.
Next
From: Pavel Stehule
Date:
Subject: Re: Avoiding bad prepared-statement plans.