Re: Multiple-Table-Spanning Joins with ORs in WHERE Clause

Поиск
Список
Период
Сортировка
От Pavel Stehule
Тема Re: Multiple-Table-Spanning Joins with ORs in WHERE Clause
Дата
Msg-id CAFj8pRDu3HEG6EYURtvayjiaF2Uj-UiTxnww7dzW6eO8kV5tyw@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Multiple-Table-Spanning Joins with ORs in WHERE Clause  ("Sven R. Kunze" <srkunze@mail.de>)
Ответы Re: Multiple-Table-Spanning Joins with ORs in WHERE Clause
Re: Multiple-Table-Spanning Joins with ORs in WHERE Clause
Список pgsql-performance


2016-09-29 14:20 GMT+02:00 Sven R. Kunze <srkunze@mail.de>:
On 23.09.2016 11:00, Pavel Stehule wrote:
2016-09-23 8:35 GMT+02:00 Sven R. Kunze <srkunze@mail.de>:
I was wondering: would it be possible for PostgreSQL to rewrite the query to generate the UNION (or subquery plan if it's also fast) on it's own?

It depends on real data. On your specific data the UNION variant is pretty fast, on different set, the UNION can be pretty slow. It is related to difficult OR predicate estimation.

I figure that the UNION is fast if the sub-results are small (which they are in our case). On the contrary, when they are huge, the OUTER JOIN variant might be preferable.


Is there something I can do to help here?

Or do you think it's naturally application-dependent and thus should be solved with application logic just as we did?

In ideal world then plan should be independent on used form. The most difficult is safe estimation of OR predicates. With correct estimation the transformation to UNION form should not be necessary I am think.

Regards

Pavel



Cheers,
Sven

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

Предыдущее
От: Jeff Janes
Дата:
Сообщение: Re: Multiple-Table-Spanning Joins with ORs in WHERE Clause
Следующее
От: "Sven R. Kunze"
Дата:
Сообщение: Re: Multiple-Table-Spanning Joins with ORs in WHERE Clause