Re: LIKE pattern

From: SoDupuDupu <playtoh87(at)gmail(dot)com>
To: pgsql-performance(at)postgresql(dot)org
Subject: Re: LIKE pattern
Date: 2016-05-09 21:41:06
Message-ID: 1462830066860-5902701.post@n5.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Владимир-3 wrote
> It seems my quite complex query runs 10 times faster on "some_column
> LIKE '%test_1' " vs "some_column LIKE 'test_1' "
> So I just add "%" to the pattern...

Keep in mind then LIKE '%test_1' and LIKE 'test_1' are not equivalent, using
the % as a prefix to the argument means that the scan only has to confirm
that the value ends in 'test_1' where forgoing the % entirely means that you
are essentially saying some_column='test_1'.

--
View this message in context: http://postgresql.nabble.com/LIKE-pattern-tp5902225p5902701.html
Sent from the PostgreSQL - performance mailing list archive at Nabble.com.

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Robert Klemme 2016-05-12 15:13:18 Re: LIKE pattern
Previous Message Владимир 2016-05-06 09:48:01 LIKE pattern