What are the benefits of left outer join vs nested aggregate selects to find the newest rows in a table?
Posted
by
RenderIn
on Stack Overflow
See other posts from Stack Overflow
or by RenderIn
Published on 2011-05-03T14:55:22Z
Indexed on
2011/06/29
8:22 UTC
Read the original article
Hit count: 347
I'm doing:
select * from mytable y
where y.year = (select max(yi.year)
from mytable yi
where yi.person = y.person)
Is that better or worse from a performance aspect than:
select y.* from mytable y
left outer join mytable y2
on y.year < y2.year
and y.person = y2.person
where y2.year is null
The explain plan/anecdotal evidence is inconclusive so I am wondering if in general one is better than the other.
© Stack Overflow or respective owner