Can I get better performance using a JOIN or using EXISTS?

前端 未结 12 1834
鱼传尺愫
鱼传尺愫 2020-12-03 13:04

I have two tables Institutions and Results and I want to see if there are any results for institutions that way I can exclude the ones that don\'t have results.

Can

12条回答
  •  不思量自难忘°
    2020-12-03 14:02

    If the RESULTS table has more than one row per INSTITUTION, EXISTS() has the added benefit of not requiring you to select distinct Institutions.

    As for performance, I have seen joins, IN(), and EXISTS() each be fastest in a variety of uses. To find the best method for your purposes you must test.

提交回复
热议问题