MySQL认为子查询不是在派生的! [英] MySQL thinks subquery is derived when it is not!

查看:102
本文介绍了MySQL认为子查询不是在派生的!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

MySql的结果告诉我子查询是派生的.但这不是!

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

(我知道可以很容易地将其重写为JOIN,但是我想知道为什么MySQL认为这是一个依赖的子查询.)

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

推荐答案

这是MySQL查询优化器中的错误.看起来,如果子查询中的表与主查询中的表匹配,则即使显然不应该将其视为从属子查询,也没有容易解决的方法.对不起;参加吧.

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.

这篇关于MySQL认为子查询不是在派生的!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆