mysql in conditions of inquiry in the end will not use the index

MySQL's query in the above version 5.5 are innodb storage engine, and under normal circumstances would take the index of! As for MyISAM not tried!

If the previous version 5.5 does not go the index, after the release of 5.5, MySQL optimized. MySQL 5.5 version released in 2010, the optimizer in operator can be automatically optimized for the establishment of a column index can use the index, the index of the column or will not take a full table scan.

Prior to version 5.5 select * from a where id in (select id from b); this sql statement execution plan is not really its first check out all the id b table, and then compared with the id a table. mysql will exists in the sub-query into a correlated subquery, so it is actually equivalent to this sql statement: select * from a where exists (select *

from b where b.id = a.id), performs correlated subquery exists principles are: cyclic and b taken each table a table record are compared, the comparison condition is a.id = b.id. See whether a table id of each record in the table b is present, if this is present on the line to return a record table.

Guess you like

Origin www.cnblogs.com/liuxd/p/11702697.html