Re: Avoiding sequential scans with OR join condition

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Avoiding sequential scans with OR join condition
Дата
Msg-id 4234.1097943318@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Avoiding sequential scans with OR join condition  (Mike Mascari <mascarm@mascari.com>)
Список pgsql-general
Mike Mascari <mascarm@mascari.com> writes:
> SELECT big_table.*
> FROM little_table, big_table
> WHERE little_table.x = 10 AND
> little_table.y IN (big_table.y1, big_table.y2);

> Is there any way to write the first query such that indexes will be used?

I'm afraid you're stuck with the UNION workaround.  The planner's
treatment of OR indexscans is entirely separate from its treatment of
join indexscans, so it's just not capable of forming the sort of plan
you are envisioning.  It'd be nice to improve that someday, but it'd
take either a pile of duplicate code, or a fairly thorough rewrite
of indxpath.c/orindxpath.c.

            regards, tom lane

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

Предыдущее
От: "Mark Dexter"
Дата:
Сообщение: Re: Complex Update Queries with Fromlist
Следующее
От: Michael Fuhr
Дата:
Сообщение: Re: plpgsql loop not returning value