mysql查询当前运行的长会话及优化(添加复合索引,收集统计信息)

select * from information_schema.PROCESSLIST where command='Query' and time >1 order by time desc LIMIT 10;
select * from information_schema.PROCESSLIST where command='Query' and time >40;
select concat('kill ',id,';'),time from information_schema.PROCESSLIST where command='Query' and time >10;
select concat('kill ',id,';'),time,host from information_schema.PROCESSLIST where command='Query' and time >10;
select db from information_schema.PROCESSLIST where command='Query' and time >1 ;

select user,host from mysql.user;
show grants;
show engine innodb status \G
show global variables like '%pool%';
SET GLOBAL innodb_buffer_pool_size=75010241024*1024;
select 534723428352/1024/1024/1024;
set global eq_range_index_dive_limit=600;

删除索引:
alter table cpu_sourcing.ipu_pu_req drop index idx_psn_dept1;

收集表的统计信息:
analyze table cpu_sourcing.ipu_pu_req;

创建索引:where条件中 and 多个列时,可以考虑创建复合索引
create index idx_psn_dept1 on cpu_sourcing.ipu_pu_req(enterprise_id,assign_psn,assign_dept);

posted @ 2025-03-04 18:01  ocmji  阅读(40)  评论(0)    收藏  举报