Обсуждение: limit and other joined tables

Поиск
Список
Период
Сортировка

limit and other joined tables

От
Ivan Sergio Borgonovo
Дата:
Is the planner/optimiser smart enough to join just after the LIMIT
in a similar situation:

select [columns from A, B and C] from A
join B on A.Aid=B.Bid
join C on A.Aid=C.Cid
where (conditions on A and B columns)
order by [columns from A and B]
limit 10;

What about a similar situation with subselects?

select [columns from A, B, C] from (
 select [column from A, B]
   where (conditions on A and B columns)
) s
join C on s.Aid=C.Cid
order by [columns from A, B]
limit 10;

vs

select [columns from A, B, C] from (
 select [column from A, B]
  order by [columns from A, B]
  limit 10
) s
join C on s.Aid=C.Cid;

Can postgresql take advantage of the LIMIT even if it is in the
outer select?

--
Ivan Sergio Borgonovo
http://www.webthatworks.it