Why did I use not in != on mysql 5.7 today to use the index? I read many articles saying that the index will become invalid. Is it because mysql has been updated? Now those query conditions will cause index failure
淡淡烟草味2017-05-18 10:48:28
not in or != will cause index failure, which is not absolute. It will be invalid in scenarios where the data is relatively uniform. However, if the fields with seriously uneven business data are indexed, it will not necessarily be invalid. MySQL will make its own judgment, and it is not absolute. Determine not to use an index. For example, the gender column of table A has 10,000 male entries and 20 female entries. When sex!='male', you can use the index. Similarly, if you have sex='male', you will not use the index. MySQL will choose the best one. Search method