mysql慢sql优化流程
#查询慢sql
select db,time,info from INFORMATION_SCHEMA.processlist where info is not null;
#查看执行计划
explain SELECT COUNT(1) FROM tables_name WHERE valid = 1 ;
#查看表索引
show index from tables_name;
#查看表数据
select count(*) from tables_name; select count(*) from tables_name limit 10;
#创建索引
create index inde_org_time on tables_name(create_org_id,create_time)
#执行计划验证结果
explain SELECT COUNT(1) FROM tables_name WHERE valid = 1 ;
做一个决定,并不难,难的是付诸行动,并且坚持到底。