Sometimes a field in a table clearly has an index. When we observe that the execution plan of some statements does not go through the index, what should we do? How can this problem be solved?

Source: Internet
Author: User
Why is there a clear index for a field in a table sometimes? How can this problem be solved?

A. There are several reasons why indexes are not taken away:
♀You are using the all_rows method at the instance level.
♀Statistical information of your table (the most likely reason)
♀Your table is small. As mentioned above, the Oracle optimizer does not think it is worth indexing.
B. Solution
♀You can modify the optimizer_mode parameter in init <Sid>. ora to rule or choose to restart the database. You can also use the hint mentioned in 4.
♀Delete statistics
SQL> analyze table table_name Delete statistics;
♀It is correct that the table is small and does not take indexes.

Other problems

A. How to check whether a table or index is statistical information?

SQL> select * From user_tables
2 Where table_name = <table_name>
3 and num_rows is not null;

SQL> select * From user_indexes
2 Where table_name = <table_name>
3 and num_rows is not null;

B. if we use the CBO method first, we should update the statistical information of tables and indexes in a timely manner, so as not to generate realistic execution plans.

SQL> analyze table table_name compute statistics;
SQL> analyze index index_name estimate statistics;

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.