1.碎片整理
现象:DELETE只是将数据标识位删除,并没有整理数据文件,当插入新数据后,会再次使用这些被置为删除标识的记录空间
解决:可以使用如下来回收未使用的空间,并整理数据文件的碎片。
optimise table【tableName】
解析:查询缓存的db信息:
select * from tables order by table_rows desc; //查询数据行数
2.查询慢sql:
select *from information_schema.processlist where info is not null
— and state like ‘%send%’
order by time desc;
3.开启慢sql
set global long_query_time=2;
show variables like “%slow%”;
show variables like “%long%”;
set global slow_query_log=’ON’;