Wednesday 8 July 2015

JOIN or EXISTS

Both serves entirely different purposes.
You JOIN two tables to access related records. If you don't need to access the data in the related records then you have no need to join them.
EXISTS can be used to determine if a token exists in a given set of data but won't allow you to access the related records.
Suppose we have Institution and Results table,
With our two tables Institutions and Results if we want a list of institutions that have results, JOIN will be most efficient:
If you have an institution_id and just want to know if it has results, using EXISTS might be faster.

No comments:

Post a Comment