Where does the practice “exists (select 1 from …)” come from?

前端 未结 4 770
无人及你
无人及你 2020-12-03 07:51

The overwhelming majority of people support my own view that there is no difference between the following statements:

SELECT * FROM tableA WHERE EXISTS (SELE         


        
4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-03 08:12

    The main part of your question is - "where did this myth come from?"

    So to answer that, I guess one of the first performance hints people learn with sql is that select * is inefficient in most situations. The fact that it isn't inefficient in this specific situation is hence somewhat counter intuitive. So its not surprising that people are skeptical about it. But some simple research or experiments should be enough to banish most myths. Although human history kinda shows that myths are quite hard to banish.

提交回复
热议问题