"T.J.Farrell" <[EMAIL PROTECTED]> 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 via email to