Re: NOT LIKE index support

From: Andreas Karlsson <andreas(at)proxel(dot)se>
To: Arjen Nienhuis <a(dot)g(dot)nienhuis(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: NOT LIKE index support
Date: 2016-03-15 23:04:07
Message-ID: 56E894E7.3020800@proxel.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 03/15/2016 11:01 PM, Arjen Nienhuis wrote:
> I noticed index support for NOT LIKE is missing. Is there a special
> reason for that, or would a patch be accepted?
>
> A use case would be:
>
> ... WHERE url NOT LIKE 'http%'
>
> Or
>
> ... WHERE path NOT LIKE '/%'

My guess is the lack of many compelling use cases for such a feature.
Indexes are generally only useful for expressions with a high
selectivity (i.e. where you match a small percentage of the rows in the
table), and in most cases NOT LIKE would match more than half of the
rows in the table causing the query planner to prefer doing a sequential
scan. And your examples above seem like they would match most rows in
the table, making an index scan rarely worth it.

We do not have support for indexing the <> operator either for btree
indexes.

Andreas

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2016-03-15 23:58:10 Re: Parallel Aggregate
Previous Message David Rowley 2016-03-15 22:55:55 Re: Parallel Aggregate