创建索引
如以下 索引名称、表名、字段名称
create index idx_ uid on t_ content(uid);|
删除索引
如以下 索引名称、表名
drop index idx_ uid on t_ content;|
删除冗余索引
1、使用以下工具检查哪些索引是冗余的
百度搜索 percona toolkit 进入官网选择对应的版本和平台目前不支持windows系统工具使用如图:
如图以下是生成的报告 箭头指示的就是推荐移除掉的索引
2、索引使用情况使用以下SQLSELECT
object_type,object_schema,object_name,index_name,
count_read,count_fetch, count_insert,
count_update,count_delete
FROM
performance_schema.table_io_waits_summary_by_index_usage
ORDER BY
sum_timer_wait desc;3、索引重新统计
analyze table t_content;
4、optimize 优化表空间,释放表空间,释放时会导致锁表,一定要在维护期间,否则会造成IO阻塞
optimize table t_content;