logo       

Re: [HACKERS] potential bug with query optimizer and functions: msg#01809

pgsql-hackers

Subject: Re: [HACKERS] potential bug with query optimizer and functions

On Mon, Jul 27, 2009 at 3:15 PM, Zach Conrad<zach.conrad@xxxxxxxxxxxxxx> wrote:
> While creating a function, I kept getting a large variance in runtime between
> the raw query vs. using the function/prepared statement. After talking with
> folks on #postgresql, specifically David Fetter, he thought I should mention
> it 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

--
Sent via pgsql-hackers mailing list (pgsql-hackers@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | Mail Home | sitemap | FAQ | advertise