Heim >Datenbank >MySQL-Tutorial >数据库优化-删除不再使用的索引

数据库优化-删除不再使用的索引

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-07 16:05:191085Durchsuche

ENV:11.2.0.3 一个运行了四年的库,近期发现一些头疼的问题,空间不足,性能降低 发现有些索引因为应用变更,基本不用了,决定检测,删除那些不同的索引; 以前也有写过博文:http://blog.csdn.net/jacson_bai/article/details/37773319 这里涉及到公司一些

ENV:11.2.0.3

一个运行了四年的库,近期发现一些头疼的问题,空间不足,性能降低

发现有些索引因为应用变更,基本不用了,决定检测,删除那些不同的索引;
以前也有写过博文:http://blog.csdn.net/jacson_bai/article/details/37773319
这里涉及到公司一些安全,就不贴出来了,主要说一下解决思路

数据库每一个schema下所有操作都相同:
1.开启索引监控
select 'alter index '||index_name||' monitoring usage;' from user_indexes;
将查询结果写在一个1.sql文本,调用sqlplus执行。
2.监控程序运行,这个是需要时间的,尤其是有PL/SQL写的那些对象,必须都运行了,才可以下结论
有时候可能需要一个月,因为有些job就是每月运行一下
3.关闭索引监控
select 'alter index '||index_name||' nomonitoring usage;' from user_indexes;
将查询结果写在一个2.sql文本,调用sqlplus执行
4.查看监控结果
select * from v$object_usage;

关键看,USE是YES还是NO

5.将结果导出来,与开发讨论后,的确没有再使用的,就drop

备注:有些schema可能没有权限执行alter哦,要么赋权限再拿掉,要么有补全schema,在sysdba下执行

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn