Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Performance of the query based on timestamp vs date comparison

779375May 3 2011 — edited May 3 2011
Hello, All,

I have a set of tables changes in which are tracked by LAST_MODIFIED field (timestamp, which is updated every time respective record gets changed). All those tables are going to be big ones - up to 7M of records in each

There is an index on LAST_MODIFIED for all those tables, but still queries like 'select * from TABLE where LAST_MODIFIED > sample_timestamp' are quite slow (approximately 2-3 sec for 1M of records).

What I noticed that running a query like this - 'select * from TABLE where LAST_MODIFIED > sample_timestamp+0' gives 50-60 times speedup but as far as I understand adding 0 converts TIMESTAMP to DATE (therefore cutting milliseconds which are important).

So the questions are:
1. why my original query is so slow? Are indices built on TIMESTAMP fields not effective in general?
2. Is there a way to cheat Oracle by doing some similar trick like I did but with no losing milliseconds?

Thank you very much!

Max
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 31 2011
Added on May 3 2011
12 comments
9,007 views