pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Андрей Хозов <avkhozov@gmail.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Performance issue with castings args of the function
Date: Mon, 02 Jan 2017 11:36:20 -0500
Message-ID: <18071.1483374980@sss.pgh.pa.us> (raw)
In-Reply-To: <CAA_oMnM4AGAofZLi-N1dBQ542DcWxtk3PpiRhdKOiQqLfP9xjg@mail.gmail.com>
References: <CAA_oMnM4AGAofZLi-N1dBQ542DcWxtk3PpiRhdKOiQqLfP9xjg@mail.gmail.com>
List-Unsubscribe:  <mailto:majordomo@postgresql.org?body=unsub%20pgsql-performance>

=?UTF-8?B?0JDQvdC00YDQtdC5INCl0L7Qt9C+0LI=?= <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


-- 
Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance



view thread (4+ messages)  latest in thread

Message-ID: <18071.1483374980@sss.pgh.pa.us>
Permalink:  ../18071.1483374980@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/18071.1483374980@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: tgl@sss.pgh.pa.us, avkhozov@gmail.com
  Subject: Re: Performance issue with castings args of the function
  In-Reply-To: <18071.1483374980@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox