SELECT `sname` FROM` stu` WHERE ` age` + 10 = 30; - not use the index, because the calculation involved in all index columns
SELECT` sname` FROM `stu` WHERE LEFT (` date`, 4) <1990 ; - do not use the index, because of the use of the function calculation, the same principle as above
SELECT * FROM `houdunwang` WHERE` uname` LIKE ' % backing' - taking the index
SELECT * FROM `houdunwang` WHERE` uname` LIKE "% % backing "- do not take the index
reason not to use regular expressions index, it should be well understood, it is difficult to see why the regexp keyword in SQL -
- string and numeric comparison without using an index;
the CREATE TABLE` a` ( `a` char (10));
EXPLAIN the sELECT *` a` the WHERE `a` the FROM =". 1 "- take the index
EXPLAIN sELECT * FROM` a` WHERE ` a` = 1 - do not take the index
select * from dept where dname = 'xxx ' or loc = 'xx' or deptno = 45 - If there are conditions or, even if use conditions are not indexed. In other words, it requires the use of all fields must be indexed, we suggest that you avoid using keywords or
- if mysql estimated using the full table scan faster than using an index, the index is not used
Examples of the index does not go away
Guess you like
Origin www.cnblogs.com/bingyunbuxi/p/11315765.html
Ranking