Re: Avoiding bad prepared-statement plans.

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Avoiding bad prepared-statement plans.
Дата
Msg-id 10153.1265905060@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Avoiding bad prepared-statement plans.  (Robert Haas <robertmhaas@gmail.com>)
Ответы Re: Avoiding bad prepared-statement plans.
Re: Avoiding bad prepared-statement plans.
Список pgsql-hackers
Robert Haas <robertmhaas@gmail.com> writes:
> On Thu, Feb 11, 2010 at 7:48 AM, Bart Samwel <bart@samwel.tk> wrote:
>> Because that's the
>> underlying assumption of the "ratio" criterion -- that re-planning with
>> filled-in parameters takes about as much time as the initial planning run
>> took.

> We only want to replan when replanning is relatively cheap compared to
> execution,

Well, no, consider the situation where planning takes 50 ms, the generic
plan costs 100ms to execute, but a parameter-specific plan would take 1ms
to execute.  Planning is very expensive compared to execution but it's
still a win to do it.

The problem that we face is that we don't have any very good way to tell
whether a fresh planning attempt is likely to yield a plan significantly
better than the generic plan.  I can think of some heuristics --- for
example if the query contains LIKE with a parameterized pattern or a
partitioned table --- but that doesn't seem like a particularly nice
road to travel.

A possible scheme is to try it and keep track of whether we ever
actually do get a better plan.  If, after N attempts, none of the custom
plans were ever more than X% cheaper than the generic one, then give up
and stop attempting to produce custom plans.  Tuning the variables might
be challenging though.
        regards, tom lane


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Robert Haas
Дата:
Сообщение: Re: [PATCH] Output configuration status after ./configure run.
Следующее
От: Alvaro Herrera
Дата:
Сообщение: Re: [PATCH] Output configuration status after ./configure run.