From: | Chris <dmagick(at)gmail(dot)com> |
---|---|
To: | Postgres User <postgres(dot)developer(at)gmail(dot)com> |
Cc: | Erik Jones <erik(at)myemma(dot)com>, pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Regex query not using index |
Date: | 2008-02-20 05:16:46 |
Message-ID: | 47BBB7BE.80106@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
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/
From | Date | Subject | |
---|---|---|---|
Next Message | Postgres User | 2008-02-20 05:29:50 | Re: Regex query not using index |
Previous Message | Robert Treat | 2008-02-20 05:00:04 | Re: postgresql book - practical or something newer? |