Re: BUG #1334: PREPARE creates bad execution plan (40x - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #1334: PREPARE creates bad execution plan (40x
Date
Msg-id 893.1101873203@sss.pgh.pa.us
Whole thread Raw
In response to Re: BUG #1334: PREPARE creates bad execution plan (40x  ("Jim C. Nasby" <decibel@decibel.org>)
Responses Re: BUG #1334: PREPARE creates bad execution plan (40x
List pgsql-bugs
"Jim C. Nasby" <decibel@decibel.org> writes:
> FWIW this is a hard problem; Oracle is the only database I know of
> that's tackled it.

It seems fair to point out that this is the tradeoff you must buy into
when using PREPARE.  You can have a query plan that is tailored to the
specific parameter value you supply, or you can have a generic query
plan.  The tailored plan will cost you planning time; the generic plan
will save you planning time; but there's no free lunch.  If your table
statistics are such that you really need different plans for different
parameter values, then you shouldn't be using PREPARE.  I do not think
this is a database bug --- it looks more like DBA misuse of the
available tools.

            regards, tom lane

pgsql-bugs by date:

Previous
From: "Jim C. Nasby"
Date:
Subject: Re: BUG #1334: PREPARE creates bad execution plan (40x
Next
From: Bruce Momjian
Date:
Subject: Re: BUG #1334: PREPARE creates bad execution plan (40x