Re: Terrible plan for join to nested union

От: Tom Lane
Тема: Re: Terrible plan for join to nested union
Дата: ,
Msg-id: 3857.1341762995@sss.pgh.pa.us
(см: обсуждение, исходный текст)
Ответ на: Re: Terrible plan for join to nested union  (Nate Allan)
Ответы: Re: Terrible plan for join to nested union  (Nate Allan)
Список: pgsql-performance

Скрыть дерево обсуждения

Terrible plan for join to nested union  (Nate Allan, )
 Re: Terrible plan for join to nested union  (Tom Lane, )
  Re: Terrible plan for join to nested union  (Nate Allan, )
   Re: Terrible plan for join to nested union  (Pavel Stehule, )
    Re: Terrible plan for join to nested union  (Nate Allan, )
   Re: Terrible plan for join to nested union  (Tom Lane, )
    Re: Terrible plan for join to nested union  (Nate Allan, )
     Re: Terrible plan for join to nested union  (Tom Lane, )
      Re: Terrible plan for join to nested union  (Nate Allan, )

Nate Allan <> writes:
> It seems to me that the join condition (and hence the restriction) should be pushed down into both sides of the union
tobring the cardinality limit from millions to 1.  I'm imagining a rewrite like this:   
>     R(a) J (b U c)  ->  (b J R(a)) U (c J R(a))
> ...where R = Restrict, J = Join, U = Union

[ eyes that suspiciously ... ]  I'm not convinced that such a
transformation is either correct in general (you seem to be assuming
at least that A's join column is unique, and what is the UNION operator
supposed to do with A's other columns?) or likely to lead to a
performance improvement in general.

We possibly could push down a join condition on the inner side of a
nestloop, similarly to what's done in the UNION ALL case ... but that
would require a complete refactoring of what the planner does with
UNIONs.  By and large, very little optimization effort has been put
into non-ALL UNION (or INTERSECT or EXCEPT).  You should not expect
that to change on a time scale of less than years.

            regards, tom lane


В списке pgsql-performance по дате сообщения:

От: Tom Lane
Дата:
Сообщение: Re: Terrible plan for join to nested union
От: Nate Allan
Дата:
Сообщение: Re: Terrible plan for join to nested union