ILIKE

Started by Peter Eisentrautabout 23 years ago25 messageshackers
Jump to latest
#1Peter Eisentraut
peter_e@gmx.net

AFAICT, ILIKE cannot use an index. So why does ILIKE even exist, when
lower(expr) LIKE 'foo' provides a solution that can use an index and is
more standard, too?

--
Peter Eisentraut peter_e@gmx.net

#2Mark Woodward
pgsql@mohawksoft.com
In reply to: Peter Eisentraut (#1)
Re: ILIKE

I am not familiar with ILIKE, but I suspect that if people are moving
from a platfrom on which it exists, or even creatingmulti-platform
applications, there may be a substancial amount of code that may use it.

Peter Eisentraut wrote:

Show quoted text

AFAICT, ILIKE cannot use an index. So why does ILIKE even exist, when
lower(expr) LIKE 'foo' provides a solution that can use an index and is
more standard, too?

#3Vince Vielhaber
vev@michvhf.com
In reply to: Mark Woodward (#2)
Re: ILIKE

On Sat, 22 Feb 2003, mlw wrote:

I am not familiar with ILIKE, but I suspect that if people are moving
from a platfrom on which it exists, or even creatingmulti-platform
applications, there may be a substancial amount of code that may use it.

I don't know about other platforms but I've been using it in scripts for
a couple of years.

Vince.
--
Fast, inexpensive internet service 56k and beyond! http://www.pop4.net/
http://www.meanstreamradio.com http://www.unknown-artists.com
Internet radio: It's not file sharing, it's just radio.

#4Peter Eisentraut
peter_e@gmx.net
In reply to: Mark Woodward (#2)
Re: ILIKE

mlw writes:

I am not familiar with ILIKE, but I suspect that if people are moving
from a platfrom on which it exists, or even creatingmulti-platform
applications, there may be a substancial amount of code that may use it.

But there are no other systems on which it exists.

--
Peter Eisentraut peter_e@gmx.net

#5Josh Berkus
josh@agliodbs.com
In reply to: Peter Eisentraut (#4)
Re: ILIKE

Peter,

Several reasons (because I like lists):
- Some other databases support ILIKE and it makes porting easier.
- For tables and/or subqueries that are too small to need an index, ILIKE is
perfectly acceptable.
- It's also useful for comparing expressions, and is faster to type than
'jehosaphat' ~* '^Jehosaphat$', and certainly much faster than
lower('jehosaphat') = lower('Jehosaphat')

Why this sudden urge to prune away perfectly useful operators?

--
Josh Berkus
Aglio Database Solutions
San Francisco

#6Tom Lane
tgl@sss.pgh.pa.us
In reply to: Josh Berkus (#5)
Re: ILIKE

Josh Berkus <josh@agliodbs.com> writes:

- Some other databases support ILIKE and it makes porting easier.

Which other ones? I checked our archives and found that when we were
discussing adding ILIKE, it was claimed that Oracle had it. But I can't
find anything on the net to verify that claim. I did find that mSQL
(not MySQL) had it, as far back as 1996. Nothing else seems to --- but
Google did provide a lot of hits on pages saying that ILIKE is a mighty
handy Postgres-ism ;-)

Why this sudden urge to prune away perfectly useful operators?

My feeling too. Whatever you may think of its usefulness, it's been a
documented feature since 7.1. It's a bit late to reconsider.

regards, tom lane

#7Rod Taylor
rbt@rbt.ca
In reply to: Tom Lane (#6)
Re: ILIKE

On Sun, 2003-02-23 at 23:31, Tom Lane wrote:

Josh Berkus <josh@agliodbs.com> writes:

- Some other databases support ILIKE and it makes porting easier.

Which other ones? I checked our archives and found that when we were
discussing adding ILIKE, it was claimed that Oracle had it. But I can't
find anything on the net to verify that claim. I did find that mSQL
(not MySQL) had it, as far back as 1996. Nothing else seems to --- but
Google did provide a lot of hits on pages saying that ILIKE is a mighty
handy Postgres-ism ;-)

Isn't MySQL case insensitive by default? I know the ='s operator is
(was?)

'a' = 'A'

--
Rod Taylor <rbt@rbt.ca>

PGP Key: http://www.rbt.ca/rbtpub.asc

#8Peter Eisentraut
peter_e@gmx.net
In reply to: Josh Berkus (#5)
Re: ILIKE

Josh Berkus writes:

- Some other databases support ILIKE and it makes porting easier.

Which database would that be?

--
Peter Eisentraut peter_e@gmx.net

#9Peter Eisentraut
peter_e@gmx.net
In reply to: Tom Lane (#6)
Re: ILIKE

Tom Lane writes:

My feeling too. Whatever you may think of its usefulness, it's been a
documented feature since 7.1. It's a bit late to reconsider.

It's never too late for new users to reconsider. It's also never too late
to change your application of performance is not satisfactory.

--
Peter Eisentraut peter_e@gmx.net

#10Vince Vielhaber
vev@michvhf.com
In reply to: Peter Eisentraut (#9)
Re: ILIKE

On Mon, 24 Feb 2003, Peter Eisentraut wrote:

Tom Lane writes:

My feeling too. Whatever you may think of its usefulness, it's been a
documented feature since 7.1. It's a bit late to reconsider.

It's never too late for new users to reconsider. It's also never too late
to change your application of performance is not satisfactory.

And if performance is satisfactory?

Vince.
--
Fast, inexpensive internet service 56k and beyond! http://www.pop4.net/
http://www.meanstreamradio.com http://www.unknown-artists.com
Internet radio: It's not file sharing, it's just radio.

#11Justin Clift
justin@postgresql.org
In reply to: Peter Eisentraut (#9)
Re: ILIKE

Peter Eisentraut wrote:

Tom Lane writes:

My feeling too. Whatever you may think of its usefulness, it's been a
documented feature since 7.1. It's a bit late to reconsider.

It's never too late for new users to reconsider. It's also never too late
to change your application of performance is not satisfactory.

Well, ILIKE has been a feature for quite some time and the amount of
negative feedback we've been receiving about upgrade problems makes me
feel that _removing_ it would be detrimental. (i.e. broken applications)

As an alternative to _removing_ it, would a feasible idea be to
transparently alias it to something else, say a specific type of regex
query or something?

Regards and best wishes,

Justin Clift

--
"My grandfather once told me that there are two kinds of people: those
who work and those who take the credit. He told me to try to be in the
first group; there was less competition there."
- Indira Gandhi

#12Vince Vielhaber
vev@michvhf.com
In reply to: Justin Clift (#11)
Re: ILIKE

On Tue, 25 Feb 2003, Justin Clift wrote:

Peter Eisentraut wrote:

Tom Lane writes:

My feeling too. Whatever you may think of its usefulness, it's been a
documented feature since 7.1. It's a bit late to reconsider.

It's never too late for new users to reconsider. It's also never too late
to change your application of performance is not satisfactory.

Well, ILIKE has been a feature for quite some time and the amount of
negative feedback we've been receiving about upgrade problems makes me
feel that _removing_ it would be detrimental. (i.e. broken applications)

As an alternative to _removing_ it, would a feasible idea be to
transparently alias it to something else, say a specific type of regex
query or something?

Why screw with it for the sake of screwing with it?

Vince.
--
Fast, inexpensive internet service 56k and beyond! http://www.pop4.net/
http://www.meanstreamradio.com http://www.unknown-artists.com
Internet radio: It's not file sharing, it's just radio.

#13Tom Lane
tgl@sss.pgh.pa.us
In reply to: Vince Vielhaber (#12)
Re: ILIKE

Vince Vielhaber <vev@michvhf.com> writes:

On Tue, 25 Feb 2003, Justin Clift wrote:

As an alternative to _removing_ it, would a feasible idea be to
transparently alias it to something else, say a specific type of regex
query or something?

Why screw with it for the sake of screwing with it?

AFAICT, Peter isn't interested in changing the implementation, but in
removing it outright (to reduce our nonstandardness, or something like
that). While we've removed marginal features in the past, I think this
one is sufficiently popular that there's no chance of removing it just
on the strength of the argument that it's not standard.

The efficiency argument seemed irrelevant --- AFAICT, ILIKE is exactly
as indexable as any equivalent regex substitute, which is to say
"only if the pattern's leading characters are fixed (nonalphabetic)".

regards, tom lane

#14Justin Clift
justin@postgresql.org
In reply to: Vince Vielhaber (#12)
Re: ILIKE

Vince Vielhaber wrote:
<snip>

Why screw with it for the sake of screwing with it?

Hmmm, good point. "If it aint broke" ?

Regards and best wishes,

Justin Clift

Vince.

--
"My grandfather once told me that there are two kinds of people: those
who work and those who take the credit. He told me to try to be in the
first group; there was less competition there."
- Indira Gandhi

#15scott.marlowe
scott.marlowe@ihs.com
In reply to: Peter Eisentraut (#1)
Re: ILIKE

On Sat, 22 Feb 2003, Peter Eisentraut wrote:

AFAICT, ILIKE cannot use an index. So why does ILIKE even exist, when
lower(expr) LIKE 'foo' provides a solution that can use an index and is
more standard, too?

I would guess because for lower(expr) to work you need to make an index on
it. Since making ilike work invisibly would require the creation of an
"invisible" lower(expr) index, it would double index storage requirements
without warning the user.

To make ilike invisible it might be worth setting up a GUC that controls
automatic ilike index creation. That way ilike could either be a seq scan
all the time function, which is great for certain operations anyway, or
an automatically indexed operation.

#create_ilike_indexes = false # costs 2x storage on index of text, char,
types

I like ilike, but it's seq scan nature is a bit klunky.

#16Peter Eisentraut
peter_e@gmx.net
In reply to: Vince Vielhaber (#10)
Re: ILIKE

Vince Vielhaber writes:

It's never too late for new users to reconsider. It's also never too late
to change your application of performance is not satisfactory.

And if performance is satisfactory?

Hey, I don't want to take your ILIKE away. But at the time it was added
the claim was that it was for compatibility and now we learn that that was
wrong. That is something to make people aware of, for example in the
documentation.

--
Peter Eisentraut peter_e@gmx.net

#17Tom Lane
tgl@sss.pgh.pa.us
In reply to: Peter Eisentraut (#16)
Re: ILIKE

Peter Eisentraut <peter_e@gmx.net> writes:

Hey, I don't want to take your ILIKE away. But at the time it was added
the claim was that it was for compatibility and now we learn that that was
wrong. That is something to make people aware of, for example in the
documentation.

It already does say

: The keyword ILIKE can be used instead of LIKE to make the match case
: insensitive according to the active locale. This is not in the SQL
: standard but is a PostgreSQL extension.

What else would you want to say?

regards, tom lane

#18Josh Berkus
josh@agliodbs.com
In reply to: Tom Lane (#13)
Re: ILIKE

Four Reasons to use ILIKE, which have nothing to do with mSQL:

1) It's faster to type than most analagous regexp comparisons, and much faster
than comparing two LOWERs or two UPPERS.

2) It's a great operator for comparing two text variables or columns of small
tables where you don't want to worry about escaping the many items of regexp
punctuation.

3) It's an easy search-and-replace operator for porting applications from SQL
databases which automatically do case-insensitive comparisons using LIKE,
such as MySQL and some installations of MSSQL.

4) It's just as indexible (or not indexable) as regexp comparisons, and easier
to understand for users from the Microsoft world than regexp.

And, on a quick search, one of my applications uses ILIKE 21 times in the
built in functions and views.

--
Josh Berkus
Aglio Database Solutions
San Francisco

#19Peter Eisentraut
peter_e@gmx.net
In reply to: Josh Berkus (#18)
Re: ILIKE

Josh Berkus writes:

4) It's just as indexible (or not indexable) as regexp comparisons, and easier
to understand for users from the Microsoft world than regexp.

ILIKE is not indexible at all. Other forms of pattern comparisons are at
least indexible sometimes.

--
Peter Eisentraut peter_e@gmx.net

#20Josh Berkus
josh@agliodbs.com
In reply to: Peter Eisentraut (#19)
Re: ILIKE

Peter,

4) It's just as indexible (or not indexable) as regexp comparisons, and
easier to understand for users from the Microsoft world than regexp.

ILIKE is not indexible at all. Other forms of pattern comparisons are at
least indexible sometimes.

And how is ~* indexable?

--
Josh Berkus
Aglio Database Solutions
San Francisco

#21Tom Lane
tgl@sss.pgh.pa.us
In reply to: Peter Eisentraut (#19)
#22Hannu Krosing
hannu@tm.ee
In reply to: Tom Lane (#17)
#23Mark Woodward
pgsql@mohawksoft.com
In reply to: Peter Eisentraut (#1)
#24Andrew Sullivan
andrew@libertyrms.info
In reply to: Mark Woodward (#23)
#25Bruce Momjian
bruce@momjian.us
In reply to: Mark Woodward (#23)