Clear useless indexes in Oracle to improve DML Performance

Source: Internet
Author: User

DML performance is low. One of the most serious causes is the existence of useless indexes. All SQL insert, update, and delete operations will become slower when they need to modify a large number of indexes when each row of data is changed.
Many Oracle administrators assign an index to a column of WHERE statements in an SQL query. Although this method can make SQL run faster, the function-based Oracle index makes it possible for database administrators to allocate excessive indexes on the rows of data tables. Excessively allocating indexes seriously affects the performance of key Oracle data tables.
Before Oracle9i appeared, there was no way to determine which indexes were not used for SQL queries. Let's take a look at what methods Oracle9i provides for you to locate these indexes and delete them.
The process is quite simple. Oracle9i has a tool that allows you to monitor the use of indexes using the alter index Command. Then you can search for unused indexes and delete them from the database.
The following is a script that enables the monitoring of all indexes in a system:
Set pages 999;
Set heading off;
Spoolrun_monitor. SQL
Select
'Alter Index' | owner | '.' | index_name | 'monitoring usage ;'
From
Dba_indexes
Where
Owner not in ('sys ', 'system', 'perfstat ')
;
Spool off;
@ Run_monitor
 
Wait for a while until enough SQL statements are run on the database, and then you can query the new V $ OBJECT_USAGE view.
Select
Index_name,
Table_name,
Mon,
Used
From
V $ object_usage;
In V $ OBJECT_USAGE, a column is called USED and its value is YES or NO. Unfortunately, it won't tell you how many times Oracle has used this index, but this tool is useful for finding out unused indexes.
Note:
Set heading off -- disable the title of the result line
Spool c: \ dropTable. SQL
Select 'drop table' | table_name | ';' from user_tables;
Spool off

In this way, you can simply edit c: \ dropTable. SQL to obtain a batch SQL statement for deleting the table of the current user.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.