MySQL认为子查询不是派生的!

MySQL thinks subquery is derived when it is not!(MySQL认为子查询不是派生的!)
本文介绍了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认为子查询不是派生的!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Execute complex raw SQL query in EF6(在EF6中执行复杂的原始SQL查询)
Hibernate reactive No Vert.x context active in aws rds(AWS RDS中的休眠反应性非Vert.x上下文处于活动状态)
Bulk insert with mysql2 and NodeJs throws 500(使用mysql2和NodeJS的大容量插入抛出500)
Flask + PyMySQL giving error no attribute #39;settimeout#39;(FlASK+PyMySQL给出错误,没有属性#39;setTimeout#39;)
auto_increment column for a group of rows?(一组行的AUTO_INCREMENT列?)
Sort by ID DESC(按ID代码排序)