Re: potential bug with query optimizer and functions - Mailing list pgsql-hackers

From Robert Haas
Subject Re: potential bug with query optimizer and functions
Date
Msg-id 603c8f070907271250i401ab0e7r75f624ceded75f86@mail.gmail.com
Whole thread Raw
In response to potential bug with query optimizer and functions  (Zach Conrad <zach.conrad@digitecinc.com>)
List pgsql-hackers
On Mon, Jul 27, 2009 at 3:15 PM, Zach Conrad<zach.conrad@digitecinc.com> wrote:
> While creating a function, I kept getting a large variance in runtime between the raw query vs. using the
function/preparedstatement. After talking with folks on #postgresql, specifically David Fetter, he thought I should
mentionit here.
 

When you PREPARE with a parameter, it generates the plan without
knowing specifically which value you intend to substitute at execution
time.  Obviously, this can affect what plan gets chosen, because it's
sort of trying to make a best guess without knowing whether the actual
value will be a common one or an uncommon one.  I bet if you PREPARE
it without the parameter, you'll get the same plan as executing it
directly.

...Robert


pgsql-hackers by date:

Previous
From: Zach Conrad
Date:
Subject: potential bug with query optimizer and functions
Next
From: Devrim GÜNDÜZ
Date:
Subject: Re: SRPMs?