Mysql optimization ---- hash index optimization, mysql ---- hash

Source: Internet
Author: User

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.

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.