From: Tom Lane <tgl@sss.pgh.pa.us>
To: T.J.Farrell <T.J.Farrell@wanadoo.fr>
Cc: pgsql-sql@postgresql.org
Subject: Re: LIKE vrs ~~
Date: Sun, 04 Jun 2000 15:19:11 -0400
Message-ID: <6560.960146351@sss.pgh.pa.us> (raw)
In-Reply-To: <000601bfcd9a$c39f06e0$2c3cfac1@oemcomputer>
References: <000601bfcd9a$c39f06e0$2c3cfac1@oemcomputer>
"T.J.Farrell" <T.J.Farrell@wanadoo.fr> writes:
> I was wondering about the performance incidence of :
> SELECT * FROM table1 WHERE UPPER(field1) LIKE
> UPPER('%thomas%');
> versus:
> SELECT * FROM table1 WHERE field1 ~~ '%thomas%'
Of course "~~" is just an alternate spelling of LIKE, and is
case-sensitive, so the above two queries are not equivalent.
Perhaps you meant to refer to "~*" which is a case-insensitive
regex match ... but then you'd need a different pattern.
Anyway, if you keep an index on upper(field1) then the first form
is the way to go, since the system can use a left-anchored pattern
as an index range restriction.
regards, tom lane
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, T.J.Farrell@wanadoo.fr
Subject: Re: LIKE vrs ~~
In-Reply-To: <6560.960146351@sss.pgh.pa.us>
References: <000601bfcd9a$c39f06e0$2c3cfac1@oemcomputer> <6560.960146351@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