sql server - SQL performance on LEFT OUTER JOIN vs NOT EXISTS -
if want find set of entries in table not in table b, can use either left outer join or not exists. i've heard sql server geared towards ansi , in case left outer joins far more efficient not exists. ansi join perform better in case? , join operators more efficient not exists in general on sql server?
joe's link starting point. quassnoi covers too.
in general, if fields indexed, or if expect filter out more records (i.e. have lots of rows exist
in subquery) not exists
perform better.
exists
, not exists
both short circuit - record matches criteria it's either included or filtered out , optimizer moves on next record.
left join
join all records regardless of whether match or not, filter out non-matching records. if tables large and/or have multiple join
criteria, can very resource intensive.
i try use not exists
, exists
possible. sql server, in
, not in
semantically equivalent , may easier write. these among operators find in sql server guaranteed short circuit.
Comments
Post a Comment