Oracle index Suppression

Source: Internet
Author: User

Oracle index Suppression

Preface: in many cases of Oracle Database optimization, you can increase the database performance by adding indexes. However, in some cases, DBA cannot do anything about it, because all the indexes have been created, but the index cannot be taken due to the SQL statement written by the developer, You need to modify the statement in this case;

Test Environment Description:

Understanding ArcSDE indexes by Oracle Indexes

How to create an optimal index using Oracle Indexing Technology

Test example of the table where the NULL value of the Oracle index column triggers the execution plan

Oracle index primary key affects query speed

Oracle index Scanning

Case 1: Use of TO_CHAR and TO_DATE

The following two statements implement the same functions, but the two execution plans are different. One of them will go through the index, and the other will not go through the index:

Select count (*) From john where lastruntime> TO_DATE ('2017-03-05 11:00:00 ', 'yyyy-MM-dd HH24: mi: ss ');

Select count (*) From john where TO_CHAR (LASTRUNTIME, 'yyyy/MM/dd HH24: mi: ss')> '2017-03-05 11:00:00 ';

 

Cause: the JOHN_TIME index records the value of DATA instead of the value after to_char. Therefore, the statement will be indexed later, and Statement 2 will be scanned throughout the table;

 

Case 2: use expressions in conditions

Select count (*) From john where lastruntime> SYSDATE-100;

Select count (*) From john where LASTRUNTIME-100> SYSDATE;

 

Cause: the JOHN_TIME index records the value of DATA instead of the value after DATA-100;

Conclusion: 1. Do not add correspondence before fields easily;

2. Try not to embed fields into expressions;

All in all: the column with an index cannot perform any related operations, but it is placed separately on the side of the equation;

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.