Re: potential bug with query optimizer and functions

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Zach Conrad <zach(dot)conrad(at)digitecinc(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: potential bug with query optimizer and functions
Date: 2009-07-27 19:50:17
Message-ID: 603c8f070907271250i401ab0e7r75f624ceded75f86@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Jul 27, 2009 at 3:15 PM, Zach Conrad<zach(dot)conrad(at)digitecinc(dot)com> 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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Devrim GÜNDÜZ 2009-07-27 20:19:41 Re: SRPMs?
Previous Message Zach Conrad 2009-07-27 19:15:17 potential bug with query optimizer and functions