Re: EXISTS clauses not being optimized in the face of 'one time pass' optimizable expressions

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: EXISTS clauses not being optimized in the face of 'one time pass' optimizable expressions
Дата
Msg-id 18138.1467382269@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: EXISTS clauses not being optimized in the face of 'one time pass' optimizable expressions  (Robert Haas <robertmhaas@gmail.com>)
Ответы Re: EXISTS clauses not being optimized in the face of 'one time pass' optimizable expressions  (Merlin Moncure <mmoncure@gmail.com>)
Re: EXISTS clauses not being optimized in the face of 'one time pass' optimizable expressions  (Robert Haas <robertmhaas@gmail.com>)
Список pgsql-hackers
Robert Haas <robertmhaas@gmail.com> writes:
> On Fri, Jul 1, 2016 at 9:52 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Maybe, but neither UNION nor UNION ALL would duplicate the semantics
>> of OR, so there's some handwaving here that I missed.

> SELECT * FROM foo WHERE a = 5 OR a = 4
> isn't equivalent to
> SELECT * FROM foo WHERE a = 5
> UNION
> SELECT * FROM foo WHERE a = 4
> ?

It probably is, but you're assuming that "a" appears in the list of
columns being unioned.  If you make that just "SELECT b FROM ..."
then the latter form gets rid of duplicate b values where the first
doesn't.  On the other hand, UNION ALL might introduce duplicates
not present in the OR query's result.
        regards, tom lane



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

Предыдущее
От: Amit Kapila
Дата:
Сообщение: Re: Documentation fixes for pg_visibility
Следующее
От: Robert Haas
Дата:
Сообщение: Re: Postgres_fdw join pushdown - wrong results with whole-row reference