MySQL redundancy and duplicate Indexes

Source: Internet
Author: User
Redundancy and duplicate index redundancy and duplicate index concept: MySQL allows you to create multiple indexes on the same column, whether there is ..

Redundancy and duplicate index redundancy and duplicate index concept: MySQL allows you to create multiple indexes on the same column, whether there is ..

Redundancy and duplicate Indexing

Concept of redundancy and repeated indexing:

MySQL allows you to create multiple indexes on the same column, either intentionally or unintentionally. MySQL needs to maintain duplicate indexes separately. The Hong Kong virtual host and the optimizer also needs to consider the query optimization individually. The Hong Kong virtual host will affect the performance.

Duplicate index: an index of the same type is created on the same column in the same order. Avoid creating duplicate indexes in this way and remove them immediately after discovery.

Eg: sometimes duplicate indexes are created inadvertently.

Create table test (id int not null primary key, a int not null, INDEX (ID) ENGINE = InnoDB;

Pt-duplicate-key-checker-udbuser-pdbpaswd -- charset = gbk \ -- database = dbname

After the execution, the duplicate and redundant indexes of the dbname database will be calculated as follows:

######################################## ################################## Dbname. test1 ####################################### ################################### vkey is a left- prefix of keydesc_index # Key definitions: # KEY 'vkey' ('vehiclekey'), # KEY 'keydesc _ Index' ('vehiclekey', 'description') # Column types: # 'vehiclekey' char (8) not null default ''# 'description' char (255) not null default'' # To remove this duplicate index, execute: alter table 'dbname '. 'test1' drop index 'vkey '; ######################################## ################################## dbname. test2 ####################################### ################################### vkey is a duplicate PRIMARY # Key definitions: # KEY 'vkey' ('vehiclekey'), # primary key ('vehiclekey'), # Column types: # 'vehiclekey' varchar (8) not null default '0' # To remove this duplicate index, execute: alter table 'dbname '. 'test2 'drop index'vkey ';

It counts all repeated, redundant indexes, server space, and SQL statements to be executed. Is it convenient.

For details about all the parameters or usage of the tool, see pt-duplicate-key-checker.

This article is from the "Focus on the database" blog. Please keep this source

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.