Subqueries vs joins

前端 未结 14 1992
闹比i
闹比i 2020-11-22 16:10

I refactored a slow section of an application we inherited from another company to use an inner join instead of a subquery like:

WHERE id IN (SELECT id FROM          


        
14条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-22 16:56

    Usually its the result of the optimizer not being able to figure out that the subquery can be executed as a join in which case it executes the subquery for each record in the table rather then join the table in the subquery against the table you are querying. Some of the more "enterprisey" database are better at this, but they still miss it sometimes.

提交回复
热议问题