Join vs. sub-query

前端 未结 19 2004
广开言路
广开言路 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:33

    Use EXPLAIN to see how your database executes the query on your data. There is a huge "it depends" in this answer...

    PostgreSQL can rewrite a subquery to a join or a join to a subquery when it thinks one is faster than the other. It all depends on the data, indexes, correlation, amount of data, query, etc.

    0 讨论(0)
提交回复
热议问题