Re: Overriding the optimizer

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Overriding the optimizer
Дата
Msg-id 4252.1134804491@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Overriding the optimizer  ("Craig A. James" <cjames@modgraph-usa.com>)
Список pgsql-performance
"Craig A. James" <cjames@modgraph-usa.com> writes:
> How about this: Instead of arguing in the abstract, tell me in
> concrete terms how you would address the very specific example I gave,
> where myfunc() is a user-written function.  To make it a little more
> challenging, try this: myfunc() can behave very differently depending
> on the parameters, and sometimes (but not always), the application
> knows how it will behave and could suggest a good execution plan.

A word to the wise:

regression=# explain select * from tenk1 where ten > 5 and ten < 9
regression-# and myfunc(unique1,unique2);
                            QUERY PLAN
------------------------------------------------------------------
 Seq Scan on tenk1  (cost=0.00..533.00 rows=982 width=244)
   Filter: ((ten > 5) AND (ten < 9) AND myfunc(unique1, unique2))
(2 rows)

regression=# explain select * from tenk1 where myfunc(unique1,unique2)
regression-# and ten > 5 and ten < 9;
                            QUERY PLAN
------------------------------------------------------------------
 Seq Scan on tenk1  (cost=0.00..533.00 rows=982 width=244)
   Filter: (myfunc(unique1, unique2) AND (ten > 5) AND (ten < 9))
(2 rows)

I might have taken your original complaint more seriously if it
weren't so blatantly bogus.  Your query as written absolutely
would not have evaluated myfunc() first, because there was no
reason for the planner to reorder the WHERE list.

            regards, tom lane

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

Предыдущее
От: Mark Kirkwood
Дата:
Сообщение: Re: Should Oracle outperform PostgreSQL on a complex
Следующее
От: David Lang
Дата:
Сообщение: Re: Overriding the optimizer