Re: Regex query not using index

From: "Postgres User" <postgres(dot)developer(at)gmail(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Regex query not using index
Date: 2008-02-20 08:56:54
Message-ID: b88c3460802200056n2ed6a449j7880b192b76b47aa@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

a final question: why does this syntax do a seq scan + filter:

select * from tablea where fielda = fielda -or- select * from
tablea where fielda in (fielda)

while this syntax results in no filter, seq scan only

select * from tablea where 1 = 1

it seems that both where clauses should be ignored by the optimizer-
or am i missing something

On Feb 19, 2008 9:45 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> "Postgres User" <postgres(dot)developer(at)gmail(dot)com> writes:
> > 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.
>
> Unfortunately, Postgres is not as intelligent as you are. There is
> no mechanism to rewrite a multi-branch regex condition into multiple
> indexscans. I recommend going back to the OR's.
>
> regards, tom lane
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Martijn van Oosterhout 2008-02-20 09:02:09 Re: Regex query not using index
Previous Message Dragan Zubac 2008-02-20 08:55:07 longest prefix match