Misunderstanding of a date search in Oracle

Source: Internet
Author: User

Often in the data to retrieve the data occurred in the last month, so the use of the following statement select * from eventtable where eventdate> sysdate-30, when the amount of data is small can not see, if there is a large amount of data, you will find that the above statement is slow, but the eventdate Date field is also indexed. Why is it slow? It turns out that oracle constantly retrieves the ever-changing sysdate value while searching, instead of generating a conditional statement once we imagined and then searching. To speed up, We can first extract the date of the current day, convert it into a string, and then use the following statement for query. select * from eventtable where eventdate> to_date, yyyy-mm-dd ). The speed is actually dozens of times worse.


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.