MySQL thinks subquery is derived when it is not!

2019-04-08 16:39发布

EXPLAIN SELECT node_id 
          FROM node 
         WHERE person_id IN (SELECT person_id 
                               FROM user 
                              WHERE is_locked = 0);

Results in MySql telling me the subquery is derived. But it's not!

(I know this could easily be re-written as a JOIN, but I want to know why MySQL thinks this is a dependent subquery.)

1条回答
在下西门庆
2楼-- · 2019-04-08 17:13

This is a bug in the MySQL Query Optimizer. It would seem that, if the table in the subquery matches the table in the main query, it is considered a dependent subquery even if it obviously should not be, and there's no easy fix. Sorry; go for the join.

查看更多
登录 后发表回答