lateral join with union all

Поиск
Список
Период
Сортировка
От jian he
Тема lateral join with union all
Дата
Msg-id CACJufxEAP+L=bGPN4xPESKMkYDGZh_4qgXrahZ8mTdf24xcimA@mail.gmail.com
обсуждение исходный текст
Ответы Re: lateral join with union all  ("David G. Johnston" <david.g.johnston@gmail.com>)
Список pgsql-general
select * from
(
    (select 2 as v )
    union all
    (select 3 as v)
) as q1
cross join lateral
(   (select * from
    ((select 4 as v) union all
    (select 5 as v)) as q3
    )
    union all
    (select q1.v)
) as  q2;

I thought q1 will be materialized as a constant set and will be equivalent as  select 2 union all select 3;
Then It will  have 8 (2 * 4) rows total. Then It will be like {2,3} cross join with {2,3,4,5}

But Here the actual result(return 6 rows) feels like two separate queries(A,B) then union together.
QueryA: (select 2 as v ) cross join lateral (.....)
QueryB: (select 3 as v ) cross join lateral (.....)
Query A 3 row + Query B 3 row. So the total is 6 rows.

Then I feel a little bit confused.

--
 I recommend David Deutsch's <<The Beginning of Infinity>>

  Jian


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

Предыдущее
От: "David G. Johnston"
Дата:
Сообщение: Re: Can I get the number of results plus the results with a single query?
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: lateral join with union all