Mysql 维护基础碎片

mysql 服务状态查询

 

mysql client connection

mysql 查看进程等待时间

show full processlist;

mysql 状态明细查询

show status ; mysql

mysql Import/Expor 备份和恢复

Data Export sql

Data Importsession

 

Mysql Utilities性能

InnoDB 存储方式spa

 

TEXT 和 BLOB 的性能

1.删除text 和blob后空洞并不会处理,须要3d

OPTIMIZE TABLE movie;code

回收表空间;orm

2.合成(Synthetic )索引,提升大文本字段(text 和blob)的查询性能blog

只针对精准查询,使用MD5(),SHA1(),CRC32()等生成列散值,索引

create table t(id varchar(100), context blob,hash_value varchar(40));
insert into t values(1,repeat('beijing',2),md5(context));
insert into t values(2,repeat('beijing',2),md5(context));
insert into t values(3,repeat('beijing 2008',2),md5(context));

select*from t where hash_value=md5(repeat('beijing 2008',2));

也能够添加模糊索引

create index idx_blob on t(context(100));

select*from t where context like 'beijing%'

3.没必要要就不要检索blob和text;

如:select*from...

4.把blob和test分析到单独的表

减小主表的碎片也不会再主数表运行select*from查询大量的blob和text;

 

cmd kill session

select concat('KILL ',id,';') from information_schema.processlist
 where  command ='Sleep'
 and TIME > 100

客户端里面运行这个

打开cmd 

cd 到mysql 位置

mysq  - u admin -p

登录mysql

而后复制上面的结果到cmd

或者导出文件

select concat('KILL ',id,';') from information_schema.processlist
 where  command ='Sleep'
 and TIME > 100 
into outfile 'd:/MySQL/Temporary File/a.txt';

source d:/MySQL/Temporary File/a.sql;
相关文章
相关标签/搜索