mysql查询索引相关信息查询

#索引数大于7的表

select table_schema,table_name,count(*) count from  (select distinct TABLE_NAME,table_schema,index_NAME from information_schema.STATISTICS)A  group by table_schema,TABLE_NAME  HAVING count>7 order by count desc ;

#组合索引中字段多于5的表

select table_schema,table_name,index_NAME,count(1)  count  from information_schema.STATISTICS group by table_schema,TABLE_NAME,index_NAME  having count>5 order by count desc ;

#未使用过的索引

SELECT    a.object_schema,a.object_name,a.index_name FROM `performance_schema`.`table_io_waits_summary_by_index_usage` a  join  information_schema.tables b on  a.object_name=b.table_name WHERE a.COUNT_STAR = 0 AND a.object_schema not in ('mysql','information_schema','performance_schema`') AND a.index_name <> 'PRIMARY' AND a.SUM_TIMER_WAIT = 0  and a.index_name IS NOT NULL and b.TABLE_ROWS>100000   group by object_schema,object_name,index_name;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值