Oracle Performance Optimization Action Three: increase the scope limit for queries

Source: Internet
Author: User

Increase the scope of the query to avoid a full range of searches.

Example: The following query table record in time Actiontime less than March 1, 2001 of data:

SELECT * FROM record where Actiontime < To_date (' 20010301 ', ' yyyymm ');

The query plan indicates that the above query has a full table scan of the table, and if we know that the earliest data in the table is January 1, 2001, then we can add a minimum time,

Make the query within a full scope. Modify the following:

SELECT * FROM record where Actiontime < To_date (' 20010301 ', ' yyyymm ') and   actiontime > To_date (' 20010101 ', ' yyy Ymm ');

The latter SQL statement will take advantage of the index on the Actiontime field to improve query efficiency.

Replace ' 20010301 ' with a variable, which can be more than half the chance to improve efficiency, depending on the probability of the value being taken.

Similarly, for queries that are larger than a certain value, you can add "and column name < MAX (max)" in the WHERE clause if you know the current maximum possible value.

Oracle Performance Optimization Action Three: increase the scope limit for queries

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.