Re: Or selection on index versus union

Поиск
Список
Период
Сортировка
От kevin.kempter@dataintellect.com
Тема Re: Or selection on index versus union
Дата
Msg-id 200510041426.59158.kevin.kempter@dataintellect.com
обсуждение исходный текст
Ответ на Or selection on index versus union  (han.holl@informationslogik.nl)
Ответы Re: Or selection on index versus union  (han.holl@informationslogik.nl)
Список pgsql-general
Just a guess but have you tried using an in clause?

select something from table where fase in  ('1' , '2');




On Tuesday 04 October 2005 13:32, han.holl@informationslogik.nl wrote:
> Hello
>
> I've got a table with an index, let's call it fase.
>
> The following query is fine: 'select something from table where fase = '1';
>
> However, this is disastrously slow:
> select something from table where fase = '1' or fase = '2';
>
> The reason is that the query planner decides to ignore the index, and goes
> for a sequential scan of the table (with a couple of million records).
>
> If I do:
> select something from table where fase = '1'
> union
> select something from table where fase = '2';
>
> it's fine again, but it's a lot of typing, and the first formulation has a
> more natural feel to it.
>
> Is there a way to convince the planner to use the fase index for this type
> of query, or is there a hook somewhere that I missed that allows me to
> rewrite a query like the above with a server-side function ?
>
> Thanks in advance,
>
> Han Holl
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
>
>                http://www.postgresql.org/docs/faq

В списке pgsql-general по дате отправления:

Предыдущее
От: Steve Atkins
Дата:
Сообщение: Re: Advice on development environment for veritical product[VASCL:A105BF1C720]
Следующее
От: Aaron Smith
Дата:
Сообщение: Re: License question