From: | Андрей Хозов <avkhozov(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-performance(at)postgresql(dot)org |
Subject: | Re: Performance issue with castings args of the function |
Date: | 2017-01-02 16:52:37 |
Message-ID: | CAA_oMnPtyL_T1eOZevdRe8XwNkrpokQw_MCPdEWCZA3YSiN5Ug@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
Thanks all for explain!
On Mon, Jan 2, 2017 at 9:36 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> =?UTF-8?B?0JDQvdC00YDQtdC5INCl0L7Qt9C+0LI=?= <avkhozov(at)gmail(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Vucomir Ianculov | 2017-01-03 10:00:44 | Unable to connect to server |
Previous Message | Tom Lane | 2017-01-02 16:36:20 | Re: Performance issue with castings args of the function |