1. Singleton index and joint index
Try to use joint indexes instead of single-column indexes, because the performance of joint indexes will be relatively high. If joint indexes are used properly, you can avoid back-to-table queries. Using single-column indexes can easily cause back-to-table queries and reduce performance.
create unique index idx_phone_name on tb_user(phone,name);
When creating a joint index, which field is placed first and which field is placed later has an impact on the efficiency of query results. Due to the leftmost prefix rule, to use the entire joint index, the leftmost column must exist.
2. Index Design Principles
If the amount of data in a table exceeds one million, you need to consider building an index at this time. If there are thousands or tens of thousands of data, the query will be very fast without indexing.