function(contants) evaluated for every row

Поиск
Список
Период
Сортировка
От Bruce Momjian
Тема function(contants) evaluated for every row
Дата
Msg-id 201011241936.oAOJa8h04792@momjian.us
обсуждение исходный текст
Ответы Re: function(contants) evaluated for every row  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Someone offlist reported query slowness because we don't convert
function calls with all-constant parameters to be a constants before we
start a sequential scan:
EXPLAIN SELECT * FROM test WHERE     x >= to_date('2001-01-01', 'YYYY-MM-DD') AND     x <= to_date('2001-01-01',
'YYYY-MM-DD');                                                         QUERY
PLAN-------------------------------------------------------------------------------------------------------------------------------
SeqScan on test  (cost=0.00..58.00 rows=12 width=4)   Filter: ((x >= to_date('2001-01-01'::text, 'YYYY-MM-DD'::text))
AND(x<= to_date('2001-01-01'::text, 'YYYY-MM-DD'::text)))(2 rows)
 

Notice the to_date()'s were not converted to constants in EXPLAIN so
they are evaluated for every row.  to_date() is marked STABLE.

Is this something we should improve?

--  Bruce Momjian  <bruce@momjian.us>        http://momjian.us EnterpriseDB
http://enterprisedb.com
 + It's impossible for everything to be true. +


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

Предыдущее
От: Andres Freund
Дата:
Сообщение: Re: profiling connection overhead
Следующее
От: Tom Lane
Дата:
Сообщение: Re: function(contants) evaluated for every row