Re: Overriding the optimizer

Поиск
Список
Период
Сортировка
От Craig A. James
Тема Re: Overriding the optimizer
Дата
Msg-id 43A2251A.60907@modgraph-usa.com
обсуждение исходный текст
Ответ на Re: Overriding the optimizer  (Christopher Kings-Lynne <chriskl@familyhealth.com.au>)
Ответы Re: Overriding the optimizer
Re: Overriding the optimizer
Re: Overriding the optimizer
Список pgsql-performance

Christopher Kings-Lynne wrote:
>>>>   select * from my_table     where row_num >= 50000 and row_num <
>>>> 100000
>>>>    and myfunc(foo, bar);
>>>
>>>
>>> You just create an index on myfunc(foo, bar)
>>
>>
>> only if myfunc(foo, bar) is immutable...
>
>
> And if it's not then the best any database can do is to index scan
> row_num - so still you have no problem.

Boy, you picked a *really* bad example ;-)

The problem is that Postgres decided to filter on myfunc() *first*, and then filter on row_num, resulting in a query
timethat jumped from seconds to hours.  And there's no way for me to tell Postgres not to do that! 

So, "you still have no problem" is exactly wrong, because Postgres picked the wrong plan.  Postgres decided that
applyingmyfunc() to 10,000,000 rows was a better plan than an index scan of 50,000 row_nums.  So I'm screwed. 

Craig

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

Предыдущее
От: Christopher Kings-Lynne
Дата:
Сообщение: Re: Overriding the optimizer
Следующее
От: Mark Kirkwood
Дата:
Сообщение: Re: Overriding the optimizer