Index is a very important thing in MySQL, the common concept of the Internet is everywhere, here is not written out, the main point of their own in peacetime use a little attention in the process, in case of later self-check:
- like '%xx' Select * fromTb1whereName like '%CN';--Index not used Select * fromTb1whereName like' CN%';---Use index--use function--not using index SELECT * from TB1 where reverse (name) ='Hwan'; --Using the index SELECT * from TB1 WHERE name = Reverse ('Hwan'); -or select * from tb1 where nid = 1 or email ='Seven@live. com'; Special: When the OR condition has an unindexed columns invalidation, the following will go through the index select * from tb1 where nid = 1 or name ='Seven'; SELECT * from tb1 where nid = 1 or email ='Seven@live. com'and name ='Alex'-Inconsistent type if the column is a string type, the incoming condition must be enclosed in quotation marks, otherwise ... select * from tb1 WHERE name = 999;-! = select * from TB1 where name! = 'Alex'--all Special: If the primary key is still going to go index select * from TB1 where nid! = 123--range-> select * from TB1 where name & Gt 'Alex'Special: If the primary key or index is an integer type, then the index select * from TB1 where nid > 123 select * from TB1 where num > 123- Order BY Select e-mail from tb1 order by name Desc; When sorting by index, the selected mappings are not indexed if they are not indexes: if the primary key is sorted, then the index: SELECT * from Tb1 ORDER by nid desc; -Combined index leftmost prefix if the combined index is: (name,email) name and email--Use index name--use index email --Do not use indexes
A little supplement to MySQL index