Re: Regex query not using index - Mailing list pgsql-general

From Postgres User
Subject Re: Regex query not using index
Date
Msg-id b88c3460802192129w2338d07ctf1a7d0a5d323fcb0@mail.gmail.com
Whole thread Raw
In response to Re: Regex query not using index  (Chris <dmagick@gmail.com>)
Responses Re: Regex query not using index
Re: Regex query not using index
List pgsql-general
Yes that works, but the whole point of the exercise is replace many OR
statements with 1 regex expression.  So it's not what I'm looking for.

On Feb 19, 2008 9:16 PM, Chris <dmagick@gmail.com> wrote:
> Postgres User wrote:
> > Thanks, my dumb mistake.
> > I need to perform the equivalent of a WHERE clause OR expression using
> > regex to match exact strings.
> >
> > _________________________________________________________________________
> >
> > this example hits the index:
> > select * from eod where name ~ '^BA$'
> >
> > but when I try to add another possible value to the regex, it does a row scan:
> > select * from eod where name ~ ^BA$|^AA$'
> >
> > both of these statements return the right results, but the 2nd ignores
> > the index even though both values are left-anchored.
> >
> > any workaround- this behavior doesn't seem to make sense
>
> try changing it to
>
> select * from eod where (name ~ '^BA$' or name ~ '^AA$')
>
> though in this example they should both be name = 'XX' rather than regex'es.
>
> --
> Postgresql & php tutorials
> http://www.designmagick.com/
>

pgsql-general by date:

Previous
From: Chris
Date:
Subject: Re: Regex query not using index
Next
From: Chris
Date:
Subject: Re: Regex query not using index