Home Database Mysql Tutorial mysql优化之路----hash索引优化_MySQL

mysql优化之路----hash索引优化_MySQL

Jun 01, 2016 pm 01:05 PM
mysql optimization

创建表

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

Copy after login

//插入数据

insert into t1 (msg) values('www.baidu.com'),('www.sina.com');

Copy after login

分别给msg, crcmsg 字段添加索引

alter table t1 add index msg(msg(5));

update t1 set crcmsg=crc32(msg);

Copy after login

alter table t1 add index crcmsg(crcmsg);

Copy after login

开始做测试

最后数据表结构

根据key_len的长度的大小从而给数据库查询提高速度。

自己做的小测试,希望能够给您带来收获,祝您工作愉快。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to optimize AVG function through MySQL to improve performance How to optimize AVG function through MySQL to improve performance May 11, 2023 am 08:00 AM

How to optimize AVG function through MySQL to improve performance

Analysis of MySQL optimization and security project experience in e-commerce applications Analysis of MySQL optimization and security project experience in e-commerce applications Nov 03, 2023 am 10:42 AM

Analysis of MySQL optimization and security project experience in e-commerce applications

A complete collection of solutions to common MySQL problems A complete collection of solutions to common MySQL problems Jun 15, 2023 am 09:51 AM

A complete collection of solutions to common MySQL problems

How to properly configure and optimize MySQL's double-write buffering technology How to properly configure and optimize MySQL's double-write buffering technology Jul 25, 2023 pm 01:01 PM

How to properly configure and optimize MySQL's double-write buffering technology

How to implement MySQL underlying optimization: common techniques and principles for SQL statement optimization How to implement MySQL underlying optimization: common techniques and principles for SQL statement optimization Nov 08, 2023 pm 08:19 PM

How to implement MySQL underlying optimization: common techniques and principles for SQL statement optimization

How to optimize MySQL connection number management How to optimize MySQL connection number management Mar 16, 2024 am 08:12 AM

How to optimize MySQL connection number management

The difference between MySql and SQL optimization: The difference between MySQL optimization strategy and SQL optimization strategy The difference between MySql and SQL optimization: The difference between MySQL optimization strategy and SQL optimization strategy Jun 15, 2023 am 09:52 AM

The difference between MySql and SQL optimization: The difference between MySQL optimization strategy and SQL optimization strategy

MySQL database optimization tips: improve query efficiency MySQL database optimization tips: improve query efficiency Jun 15, 2023 pm 11:12 PM

MySQL database optimization tips: improve query efficiency

See all articles