Database optimization tutorial (8) under what circumstances should indexes be used and indexes be optimized?
Iii. Index
5. Under what circumstances should indexes be used?
Since the index has a cost, you should not use it without using the index.
1) do not use indexes for fields with poor data uniqueness
For example, gender only has two possible types of data. This means that the index has fewer Binary Tree levels, most of which are equal levels. Such binary tree search is tantamount to full table scan.
2) do not use indexes for frequently updated Fields
For example, frequent logincount logon times and index changes frequently, increasing database workload and reducing efficiency.
3) When a field does not appear in the where statement, do not add an index.
Mysql uses indexes only when the where statement appears.
4) do not use indexes for tables with a small amount of data
It has not improved much.
In addition. If mysql estimates that full table scan is faster than indexing, indexes are not used.
The end of this article is to talk about why indexes are sometimes not used by Mysql.