Home  >  Article  >  Database  >  使用ssd硬盘加速mysql index查询_MySQL

使用ssd硬盘加速mysql index查询_MySQL

WBOY
WBOYOriginal
2016-06-01 13:34:111019browse

bitsCN.com

使用ssd硬盘加速mysql index查询

 

如果数据量比较大,而ssd容量又不是很大,那么可以考虑把index索引数据存到ssd上,把表数据还是存在旧的硬盘上。

 

那么怎么让mysql把index索引建在ssd上并使用ssd上的index数据呢?

 

1.在ssd上建几个目录

 

mkdir /ssd/mysql_indexes

mkdir /ssd/mysql_indexes/my_big_db_name

chmod 700  /ssd/mysql_indexes

chown –R mysql:mysql /ssd/mysql_indexes

 

2.使用MyISAM引擎的可以在mysql的配置中添加下面配置,可以加速索引的重建

 

[mysqld]

myisam_repair_threads=10

 

3.最后我们执行下面的query让mysql切换表的索引数据位置

 

ALTER TABLE my_table INDEX DIRECTORY= '/ssd/mysql_indexes/my_big_db_name'; 

 

这个必须得等到mysql的index重建之后,才能明显感觉到数据库已经快起来了。

 

bitsCN.com
Statement:
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