Re: Suboptimal query plan fixed by replacing OR with UNION

Поиск
Список
Период
Сортировка
От Steven Schlansker
Тема Re: Suboptimal query plan fixed by replacing OR with UNION
Дата
Msg-id F1A0374B-5B7E-4E54-9B8A-197A451A486F@likeness.com
обсуждение исходный текст
Ответ на Re: Suboptimal query plan fixed by replacing OR with UNION  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Suboptimal query plan fixed by replacing OR with UNION  (Gurjeet Singh <singh.gurjeet@gmail.com>)
Список pgsql-general
On Jul 5, 2012, at 3:51 PM, Tom Lane wrote:

> Steven Schlansker <steven@likeness.com> writes:
>> Why is using an OR so awful here?
>
> Because the OR stops it from being a join (it possibly needs to return
> some rows that are not in the semijoin of the two tables).
>
>> Why does it pick a sequential scan?  Is this an optimizer bug
>
> No.  It can't transform OR into a UNION because the results might not
> be the same.  I assume you don't care about removal of duplicates, or
> have some reason to know that there won't be any ... but the planner
> doesn't know that.
>

Thanks for the insight here.  It still seems unfortunate that it picks a
sequential scan -- but if there really is no more efficient way to do this,
I will just rewrite the query.

Steven


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

Предыдущее
От: James Hartley
Дата:
Сообщение: Re: Packt's PostgreSQL 9 Administration Cookbook: LITE Editions?
Следующее
От: Keith Fiske
Дата:
Сообщение: Issue with extension updates to pg_extension table