在实现业务逻辑的时候,有些复杂一点逻辑会用数据库子查询去实现,但是sql用子查询会带来性能问题,下面就一个例子来说明,怎么优化子查询,来提升查询速度
mysql> desc update t_student_info a
-> set a.exstudentid='test01'
-> where a.studentID in
-> (select studentID from (select studentID from t_student_info where stdTYPE='8' and state=2 limit 10000,100) b);
+----+--------------------+----------------+------------+----------------+---------------+-------------+---------+------+--------+----------+-------------+
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
+----+--------------------+----------------+------------+----------------+---------------+-------------+---------+------+--------+----------+-------------+
| 1 | UPD