Re: LIKE indexing proposal

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Zeugswetter Andreas SB SD" <ZeugswetterA(at)spardat(dot)at>
Cc: "Peter Eisentraut" <peter_e(at)gmx(dot)net>, "PostgreSQL Development" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: LIKE indexing proposal
Date: 2003-05-13 14:07:02
Message-ID: 8017.1052834822@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"Zeugswetter Andreas SB SD" <ZeugswetterA(at)spardat(dot)at> writes:
> Wouldn't existing b-trees be sufficient, if they could be 'scanned' starting
> with the operator >= ? Thus a LIKE 'ABC%' could be done by stepping an (ascending)
> index fom x >= 'ABC' up to the first key that does not have 'ABC' as first
> characters ?

You've apparently forgotten all our previous history on that subject
:-(. The above does not work in the presence of special sort rules for
digraphs, etc. For example, that LIKE should certainly match ABCH ...
but there are locales in which "CH" sorts after "D" and would not be
found by an indexscan that runs from ABC to ABD.

Even with no digraphs, the optimization is broken by locales that treat
spaces as second-class citizens, prefer caseless to case-sensitive
comparisons, etc. It doesn't work in en_US locale, for example.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Zlatko Michailov 2003-05-13 14:18:52 Re: Scheduled jobs
Previous Message Tom Lane 2003-05-13 13:54:30 Re: GUC and postgresql.conf docs