"union" vs. left join

Поиск
Список
Период
Сортировка
От Emi Lu
Тема "union" vs. left join
Дата
Msg-id 49AD926E.3020406@encs.concordia.ca
обсуждение исходный текст
Ответы Re: "union" vs. left join  (ries van Twisk <pg@rvt.dds.nl>)
Список pgsql-sql
Good morning,

Would it be possible to know that whether "union" is quicker than "left 
join" in a general sense?

Queries:
========================
(1) union
select a.*, b.value
from      a
left join b   union
select a.*, c.value
from      a
left join c


(2) left join
select distinct a.*,  case when ... then     b.value  else     c.value
from      a
left join b
left join c


Will (1) be more efficient than (2) or vice versa? Or it really depends 
on data


Thanks a lot!
Lu Ying






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

Предыдущее
От: Andreas Kretschmer
Дата:
Сообщение: Re: counts of groupings by date year-month
Следующее
От: ries van Twisk
Дата:
Сообщение: Re: "union" vs. left join