Re: 7.3 no longer using indexes for LIKE queries

From: Greg Stark <gsstark(at)mit(dot)edu>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Matthew Gabeler-Lee <mgabelerlee(at)zycos(dot)com>, "'pgsql-general(at)postgresql(dot)org'" <pgsql-general(at)postgresql(dot)org>
Subject: Re: 7.3 no longer using indexes for LIKE queries
Date: 2002-12-06 00:22:39
Message-ID: 87ptsg573k.fsf@stark.dyndns.tv
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:

> [tgl(at)g3]$ echo -e "a\na a\naa\na a\nab\na b" | LC_ALL=en_US sort
> a
> aa
> a a
> a a
> ab
> a b
>
> There's no way to use an index ordered like this to look for strings
> beginning "a ", because the sorting of spaces depends on what comes
> after them.

It seems like there's an obvious easy fix for this. Allow indexes to be
created a simple non-locale dependent lexical sort order. They wouldn't be
useful for sorting in the locale sort order but they would be useful for the
case at hand.

This has the disadvantage of requiring two indexes if you really do want both
"WHERE x BETWEEN ? and ?" and "WHERE x LIKE 'foo%' to be fast, but then you're
saying that if the user really wants one of these "unsafe" locales then that's
what it'll cost the achieve it.

Perhaps a warning about it in the initdb stage since it's probably usually not
what the user wants would be nice too.

--
greg

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Philip Warner 2002-12-06 01:31:05 Re: [GENERAL] PostgreSQL Global Development Group
Previous Message scott.marlowe 2002-12-06 00:03:23 Re: Newbee question "Types"