Home  >  Article  >  Database  >  A detailed introduction to how to add an index in MySQL

A detailed introduction to how to add an index in MySQL

黄舟
黄舟Original
2017-08-02 09:47:061989browse

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,

A detailed introduction to how to add an index in MySQL

2. After writing the data, let’s query the data to see how long it will take

A detailed introduction to how to add an index in MySQL

## 3. Let’s check how much data there is in this table

A detailed introduction to how to add an index in MySQL

##4. There are three types of indexes, ordinary indexes, Unique index, full-text index

A detailed introduction to how to add an index in MySQL

5. Index method, Hash index can only satisfy "=","IN" and "" query, range query cannot be used

The most frequent index type of B-Tree

A detailed introduction to how to add an index in MySQL

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.

A detailed introduction to how to add an index in MySQL


#

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn