Performance Comparison of Oracle database date filtering methods

Source: Internet
Author: User

In the development of SQL, filter date is often encountered in the situation, how to efficiently filter out the date period? This article is validated by experiments:

Method One, compare dates into strings by To_char

To_char (cr.contractenddate, ' yyyy-mm-dd ') >= ' 2014-11-13 '
and To_char (cr.contractenddate, ' yyyy-mm-dd ') <= ' 2015-11-19 '

Time: 0.171s


Method Two, by To_date to convert the string to a date for comparison

Cr.contractenddate >= to_date (' 2014-11-13 ', ' yyyy-mm-dd ')
and Cr.contractenddate <= to_date (' 2015-11-19 ', ' yyyy-mm-dd ')

Time: 0.093s


Method Three, through the database keyword between and comparison

Cr.contractenddate
Between To_date (' 2014-11-13 ', ' yyyy-mm-dd ') and to_date (' 2015-11-19 ', ' yyyy-mm-dd ')

Time: 0.078s


Summary: Methods a time-consuming body now needs to compare each character of a string one by another;

Method two time-consuming reflected in >= and <=;

Recommended Use Method Three



Performance Comparison of Oracle database date filtering methods

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.