Thursday, January 03, 2008

Why to use Exists rather than Count(*)

Andrew Kelly : Exists Vs. Count(*) - The battle never ends...
Both queries scanned the table but the EXISTS was able to at least do a partial scan do to the fact it can stop after it finds the very first matching row. Where as the COUNT(*) must read each and every row in the entire table to determine if they match the criteria and how many there are.

No comments:

Post a Comment