Advantages and disadvantages of mysq index Establishment

Source: Internet
Author: User

Advantages and disadvantages of mysq index Establishment

 Advantages and necessity of index creation:

1. By creating a unique index, You can ensure the uniqueness of each row of data in the database table;

Second, it can greatly speed up data retrieval, which is also the main reason for creating indexes;

Third, it can accelerate the connection between tables, especially in achieving Data Reference integrity;

Fourth, when using grouping and sorting clauses for data retrieval, it can also significantly reduce the time for grouping and sorting in queries;

Fifth, by using indexes, you can use the optimizer during the query process to improve system performance;

Disadvantages of indexing:

1. It takes time to create and maintain indexes. This time increases with the increase of data volume;

2. Indexes occupy physical space. In addition to data tables, each index occupies a certain amount of physical space. If you want to create a clustered index, you need more space;

3. When adding, deleting, and modifying data in a table, the index must also be dynamically maintained, reducing the Data Maintenance speed;

 

Fields suitable for index creation:

First, you can speed up the search on columns that frequently need to be searched;

Second, in the column as the primary key, force the uniqueness of the column and the data arrangement structure in the organization table;

Third, these columns are usually used in connection columns. These columns are mainly foreign keys, which can speed up the connection;

4. Create an index on a column that often needs to be searched by range. The specified range is continuous because the index has been sorted;

Fifth, create an index on the columns that frequently need to be sorted. Because the index has been sorted, you can use the index sorting to speed up the sorting query time;

6. Create an index on a column frequently used in the WHERE clause to speed up condition judgment;

Fields not suitable for index creation:

First, indexes should not be created for columns that are rarely used or referenced in queries. This is because, since these columns are rarely used, having an index or no index does not increase the query speed. On the contrary, the addition of indexes reduces the system maintenance speed and space requirements;

Second, indexes should not be added to columns with only few data values. Adding indexes does not significantly accelerate the search speed;

Third, indexes should not be added for columns defined as text, image, and bit data types. This is because the data volume of these columns is either large or small;

Fourth, when the modification performance is far greater than the retrieval performance, you should not create an index. This is because the modification performance and retrieval performance are inconsistent. When an index is added, the search performance is improved, but the modification performance is reduced. When the index is reduced, the modification performance is improved and the retrieval performance is reduced. When the modification performance is much higher than the retrieval performance, you should not create an index.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.