Impact of rule violation:
Redundant indexes consume unnecessary space and can impact data import efficiency.
The column sequence in the composite index is incorrect, affecting the query efficiency.
Best practices:
The following conditions must be met when indexes are used:
- The index column should be a column commonly used for filtering or joining conditions.
- The index column should have more distinct values.
- When creating a multi-column combination index, prioritize columns with more distinct values.
- The number of indexes in a single table should be limited to less than five. You can control the number of indexes by combining them.
- In scenarios where data is added, deleted, or modified in batches, delete the index first and then add it back after the batch operation is complete to improve performance (real-time access may be affected).