Join vs. sub-query

前端 未结 19 2056
广开言路
广开言路 2020-11-21 05:05

I am an old-school MySQL user and have always preferred JOIN over sub-query. But nowadays everyone uses sub-query, and I hate it; I don\'t know why.

19条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-21 05:10

    Taken from the MySQL manual (13.2.10.11 Rewriting Subqueries as Joins):

    A LEFT [OUTER] JOIN can be faster than an equivalent subquery because the server might be able to optimize it better—a fact that is not specific to MySQL Server alone.

    So subqueries can be slower than LEFT [OUTER] JOIN, but in my opinion their strength is slightly higher readability.

提交回复
热议问题