当update select from的时候。当子查询返回的数据较多 外层又是张大表的时候 就会产生O(n)的情况。
比如 update table set col = 1 where aid in (select id from a1);
1,UPDATE,test_question_option,,index,,PRIMARY,4,,1398083,100,Using where
2,DEPENDENT SUBQUERY,test_question,,unique_subquery,”PRIMARY,set_id”,PRIMARY,4,func,1,5,Using where
改写成-> update join的方式去解决。
1,SIMPLE,test_question,,ref,”PRIMARY,set_id”,set_id,5,const,190,100,Using index
1,UPDATE,t1,,ref,”PRIMARY,question_id_idx”,question_id_idx,4,func,3,90,Using where
版权声明:本文为博主原创文章,未经博主允许不得转载。





