Re: LIKE and SIMILAR TO - Mailing list pgsql-general

From Ivan Sergio Borgonovo
Subject Re: LIKE and SIMILAR TO
Date
Msg-id 20080822140048.675666b8@dawn.webthatworks.it
Whole thread Raw
In response to LIKE and SIMILAR TO  ("c k" <shreeseva.learning@gmail.com>)
List pgsql-general
On Fri, 22 Aug 2008 16:43:47 +0530
"c k" <shreeseva.learning@gmail.com> wrote:

> Hello all,
> As we are migrating our ERP application from MySQL to PostgreSQL
> we have some difficulties. One of them is use of Like and Similar
> to operators. We often use LIKE to search a string from front-end
> without case sensetivity. As postgreSQL's LIKE is case sensitive,
> we tried ILIKE and SIMILAR TO, but both are slower than LIKE and
> we must need case insensitivity. How can we get this by increases
> speed. All search columns are VARCHAR(100)to VARCHAR(250).
> Currently without index.

I was going to suggest to create a functional index
create index on sometable using btree (upper(somecolumn));

select * from sometable where upper(somecolumn)
like '%' || upper(somestring) || '%';

but indexes aren't going to work if you're searching with a prefixed
%.

I was wondering what are the performances of postgresql vs. MySQL in
such case.
Anyway I'd tweak postgresql.conf before complaining it is slower
than MySQL. I've been surprised as well at how postgresql can be
fast.

--
Ivan Sergio Borgonovo
http://www.webthatworks.it


pgsql-general by date:

Previous
From: "c k"
Date:
Subject: Re: LIKE and SIMILAR TO
Next
From: Richard Huxton
Date:
Subject: Re: problem with foreign keys + data-only backup