pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedLIKE vrs ~~
3+ messages / 3 participants
[nested] [flat]
* LIKE vrs ~~
@ 2000-06-03 20:31 T.J.Farrell <T.J.Farrell@wanadoo.fr>
2000-06-04 01:46 ` Re: LIKE vrs ~~ Peter Eisentraut <peter_e@gmx.net>
2000-06-04 19:19 ` Re: LIKE vrs ~~ Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 2 replies; 3+ messages in thread
From: T.J.Farrell @ 2000-06-03 20:31 UTC (permalink / raw)
To: pgsql-sql
Hello,
I was wondering about the performance incidence of :
SELECT * FROM table1 WHERE UPPER(field1) LIKE
UPPER('%thomas%');
versus:
SELECT * FROM table1 WHERE field1 ~~ '%thomas%'
if any...
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: LIKE vrs ~~
2000-06-03 20:31 LIKE vrs ~~ T.J.Farrell <T.J.Farrell@wanadoo.fr>
@ 2000-06-04 01:46 ` Peter Eisentraut <peter_e@gmx.net>
1 sibling, 0 replies; 3+ messages in thread
From: Peter Eisentraut @ 2000-06-04 01:46 UTC (permalink / raw)
To: T.J.Farrell <T.J.Farrell@wanadoo.fr>; +Cc: pgsql-sql
T.J.Farrell 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%'
If you're comparing ~~ with LIKE then there's no difference at all. (Only
the extra cycles to convert LIKE to ~~ internally.) If you're comparing
true case-insensitive matching to using UPPER, then the latter is probably
faster but doesn't really do the same thing.
--
Peter Eisentraut Sernanders väg 10:115
peter_e@gmx.net 75262 Uppsala
http://yi.org/peter-e/ Sweden
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: LIKE vrs ~~
2000-06-03 20:31 LIKE vrs ~~ T.J.Farrell <T.J.Farrell@wanadoo.fr>
@ 2000-06-04 19:19 ` Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 0 replies; 3+ messages in thread
From: Tom Lane @ 2000-06-04 19:19 UTC (permalink / raw)
To: T.J.Farrell <T.J.Farrell@wanadoo.fr>; +Cc: pgsql-sql
"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
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2000-06-04 19:19 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2000-06-03 20:31 LIKE vrs ~~ T.J.Farrell <T.J.Farrell@wanadoo.fr>
2000-06-04 01:46 ` Peter Eisentraut <peter_e@gmx.net>
2000-06-04 19:19 ` Tom Lane <tgl@sss.pgh.pa.us>
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