Re: PL/pgSQL functions - text / varchar - havy performance

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: PL/pgSQL functions - text / varchar - havy performance
Дата
Msg-id 28309.1062173915@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: PL/pgSQL functions - text / varchar - havy performance  (Andrew Sullivan <andrew@libertyrms.info>)
Список pgsql-performance
Andrew Sullivan <andrew@libertyrms.info> writes:
> On Fri, Aug 29, 2003 at 11:34:13AM -0400, Bill Moran wrote:
>> Have any explanation as to why that function is so slow?

> Sorry, no.  It might have to do with the planning, though.

Specifically, I'll bet he's getting an indexscan plan with one and not
with the other.  It's just ye olde cross-datatype-comparisons-aren't-
indexable problem.  "varchar = varchar" matches the index on the varchar
column, but "text = text" is a different operator that doesn't match.
Guess which one gets selected when the initial input is "varchar = text".

7.4 has fixed this particular problem by essentially eliminating the
separate operators for varchar, but in prior releases the behavior
Oliver describes is entirely to be expected.  A workaround is to
cast inside the function:

    ... where varcharcolumn = textarg::varchar;

so that "=" gets interpreted as "varchar = varchar".

            regards, tom lane

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

Предыдущее
От: Ken Geis
Дата:
Сообщение: Re: bad estimates
Следующее
От: Shridhar Daithankar
Дата:
Сообщение: 2.4 v/s 2.6 again.