Mysql optimization ---- hash index optimization, mysql ---- hash
Create a table
CREATE TABLE `t1` (`id` int(11) NOT NULL AUTO_INCREMENT,`msg` varchar(20) NOT NULL DEFAULT '',`crcmsg` int(15) NOT NULL DEFAULT '0',PRIMARY KEY (`id`)) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=utf8
// Insert data
insert into t1 (msg) values('www.baidu.com'),('www.sina.com');
Add indexes to the msg and crcmsg fields respectively.
alter table t1 add index msg(msg(5));update t1 set crcmsg=crc32(msg);
alter table t1 add index crcmsg(crcmsg);
Start testing
Last data table structure
Increase the speed of database queries based on the length of key_len.
I hope you will enjoy your work and have a good time in your own small test.
How to Learn How to be familiar with MYSQL database development, configuration, maintenance, and performance optimization (index optimization, query optimization, storage optimization, and configuration optimization)
Mysql full set UHD tutorial 1 Baidu online disk download: pan.baidu.com/s/1xf59d
2. mysql optimization Tutorial: dl.vmall.com/c0a7td8xlj
How can I optimize indexes for mysql multi-table join?
1. No cross-table joint Indexes
2. t1.id t2.uid t1.name t3.username must be indexed separately.
3. It doesn't matter if there is any index when using group by. It is mainly to create related indexes for the fields on the query condition.