limit and other joined tables - Mailing list pgsql-general

From Ivan Sergio Borgonovo
Subject limit and other joined tables
Date
Msg-id 20090113130113.6ba7e51a@dawn.webthatworks.it
Whole thread Raw
List pgsql-general
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


pgsql-general by date:

Previous
From: "Dave Page"
Date:
Subject: Re: one-click installer in linux redhat-centos-fedora
Next
From: Emanuel Calvo Franco
Date:
Subject: Re: Trying to create implicit casts to text in PG 8.3