Overview

This article describes why it is invalid to change the index mode of the RDS MySQL engine table to Hash.

 

Detail

Alibaba Cloud reminds you that:

  • Before you perform operations that may cause risks, such as modifying instance configurations or data, we recommend that you check the disaster recovery and fault tolerance capabilities of the instances to ensure data security.
  • You can modify the configurations and data of instances including but not limited to Elastic Compute Service (ECS) and Relational Database Service (RDS) instances. Before the modification, we recommend that you create snapshots or enable RDS log backup.
  • If you have authorized or submitted security information such as the logon account and password in the Alibaba Cloud Management console, we recommend that you modify such information in a timely manner.
MySQL supports the following index methods: Btree, Hash, FullText, and Rtree. Btree and Hash are two common methods. After you log on to the apsaradb for RDS instance through DMS, execute DDL statements to create Hash indexes for the InnoDB engine table. The SQL statement is as follows:
drop table if exists auth_order; create table auth_order ( id smallint not null comment 'primary key', member_id varchar(30) not null comment 'membership id', name varchar(100) not null comment 'name', primary key (id), key auth_mem_name (member_id) using hash ) engine=innodb default charset=utf8 comment='membership information';
The following command output is returned.
创建Hash类型索引
We can see that the index of this table is in Hash mode. However, when looking at the table structure in DMS, we can see that the index is in B- tree mode.
Btree索引

 

The InnoDB engine of MySQL does not support Hash indexes, and the MySQL service layer supports the Hash index option. Therefore, you can use the clause usinghash in the table creation statement, but the actual index type is still created in B- tree mode.

 

Application scope

  • ApsaraDB RDS for MySQL