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 ;



posted @ 2024-04-24 17:46  苍茫宇宙  阅读(4)  评论(0编辑  收藏  举报