Re: [PERFORM] Performance issue with castings args of the function

Поиск
Список
Период
Сортировка
От Андрей Хозов
Тема Re: [PERFORM] Performance issue with castings args of the function
Дата
Msg-id CAA_oMnPtyL_T1eOZevdRe8XwNkrpokQw_MCPdEWCZA3YSiN5Ug@mail.gmail.com
обсуждение исходный текст
Ответ на Re: [PERFORM] Performance issue with castings args of the function  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-performance
Thanks all for explain!

On Mon, Jan 2, 2017 at 9:36 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
\xC1\xBA\xFFАндрей Хозо\xC1\xBA\xFFв <avkhozov@gmail.com> writes:
> create table t1 (id serial, str char(32));

> create function f1(line text) returns void as $$
> begin
>   perform * from t1 where str = line;
> end;
> $$ language plpgsql;

This query is specifying a text comparison (text = text operator).
Since the table column isn't text, a char-to-text conversion must
happen at each line.

> create function f2(line char) returns void as $$
> begin
>   perform * from t1 where str = line;
> end;
> $$ language plpgsql;

This query is specifying a char(n) comparison (char = char operator).
No type conversion step needed, so it's faster.

                        regards, tom lane



--
​Andrey Khozov

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: [PERFORM] Performance issue with castings args of the function
Следующее
От: Vucomir Ianculov
Дата:
Сообщение: [PERFORM] Unable to connect to server