Re: Understanding sequential versus index scans.

Поиск
Список
Период
Сортировка
От Robert James
Тема Re: Understanding sequential versus index scans.
Дата
Msg-id e09785e00907191710q7368d50fx2589b5005f49d7cf@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Understanding sequential versus index scans.  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Understanding sequential versus index scans.
Re: Understanding sequential versus index scans.
Список pgsql-general
UNION was better, but still 5 times as slow as either query done individually.
set enable_seqscan=off didn't help at all - it was totally ignored
Is there anything else I can do?

On Sun, Jul 19, 2009 at 7:47 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Robert James <srobertjames@gmail.com> writes:
> Hi.  I notice that when I do a WHERE x, Postgres uses an index, and when I
> do WHERE y, it does so as well, but when I do WHERE x OR y, it
> doesn't.

It can use indexes for OR conditions, but not for arbitrary OR
conditions...

> select * from dict
> where
>  word in (select substr('moon', 0, generate_series(3,length('moon')))) --
> this is my X above
>  OR word like 'moon%' -- this is my Y above

... and that one is pretty arbitrary.  You might have some luck with
using a UNION instead, viz

select * from dict where X
union all
select * from dict where Y

                       regards, tom lane

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

Предыдущее
От: Robert James
Дата:
Сообщение: Should I CLUSTER on PRIMARY KEY
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: timestamp with time zone tutorial