title: Query performance with concatenation and LIKE
body: <p>Can someone explain the performance difference between these 3 queries?</p>
  
  <p><code>concat()</code> function:</p>
  
  <pre><code>explain analyze 
  select * from person 
  where (concat(last_name, ' ', first_name, ' ', middle_name) like '%Ива%');
  
  Seq Scan on person  (cost=0.00..4.86 rows=1 width=15293) (actual time=0.032..0.140 rows=6 loops=1)
    Filter: (pg_catalog.concat(last_name, ' ', first_name, ' ', middle_name) ~~ '%Ива%'::text)
  Total runtime: 0.178 ms
  </code></pre>
  
  <p>SQL standard concatenation with <code>||</code>:</p>
  
  <pre><code>explain analyze 
  select * from person 
  where ((last_name || ' ' || first_name || ' ' || middle_name) like '%Ива%');
  
  Seq Scan on person  (cost=0.00..5.28 rows=1 width=15293) (actual time=0.023..0.080 rows=6 loops=1)
    Filter: ((((((last_name)::text || ' '::text) || (first_name)::text) || ' '::text) || (middle_name)::text) ~~ '%Ива%'::text)
  Total runtime: 0.121 ms
  </code></pre>
  
  <p>Search fields separately:</p>
  
  <pre><code>explain analyze 
  select * from person 
  where (last_name like '%Ива%') or (first_name like '%Ива%') or (middle_name like '%Ива%');
  
  Seq Scan on person  (cost=0.00..5.00 rows=1 width=15293) (actual time=0.018..0.060 rows=6 loops=1)
    Filter: (((last_name)::text ~~ '%Ива%'::text) OR ((first_name)::text ~~ '%Ива%'::text) OR ((middle_name)::text ~~ '%Ива%'::text))
  Total runtime: 0.097 ms
  </code></pre>
  
  <p>Why is <code>concat()</code> slowest one and why are several <code>like</code> conditions faster?</p>