Home >Database >Mysql Tutorial >A detailed introduction to how to add an index in MySQL
Mysql is a relational database management system that can be used in development. When the amount of data is relatively large, it is found to be slow during query. At this time, it is necessary to optimize the SQL statement. Today's introduction A way to optimize sql.
1. First I create a table, then add some data, and write a stored procedure to write the data,
2. After writing the data, let’s query the data to see how long it will take
## 3. Let’s check how much data there is in this table
##4. There are three types of indexes, ordinary indexes, Unique index, full-text index
5. Index method, Hash index can only satisfy "=","IN" and "" query, range query cannot be used
The most frequent index type of B-Tree
6. After adding the index value, query the data and see how many seconds it took. This time it is 0.5 seconds. If the amount of data is relatively large, the effect of adding the index can be seen. The effect is more obvious.
#
The above is the detailed content of A detailed introduction to how to add an index in MySQL. For more information, please follow other related articles on the PHP Chinese website!