Reputation: 1028
Basing on your experience with Oracle, what will be the best type and settings for index that you would set on a column of DATE type?
Will it be fair to create a cluster index?
What I'm interested in is to optimize execution of queries like SELECT * FROM Log WHERE [Date] > '20-06-2009' ORDER BY [Date] DESC, not slowing down inserts massively. (btw. in real world I would use the correct TO_DATE syntax to avoid truncation and missing the index)
Cheers,
Upvotes: 3
Views: 13285
Reputation: 60262
I would reconsider partitioning, depending on the volume of data - Oracle can use partition pruning when running the query - which carries the benefit of also being able to easily archive old log data later on.
Upvotes: 1
Reputation: 52336
A regular b-tree index would be appropriate, but if this is a log table with increasing values on the date then look out for index block contention. If you have a lot of sessions inserting new values into the index and those values belong in the same block then you could hit a performance problem. One mitigation for this is a reverse key index, but that makes queries of the type you give more expensive because reverse key indexes cannot support range scans. You would get a full index scan or a fast full index scan instead.
It would also make the index larger because the index block splits would be 50/50, instead of the 90/10 that Oracle uses when it detects a rightward growth pattern in the indexed values.
Upvotes: 5
Reputation: 1433
A regular index should do just fine. Since it is a log the new entries should always have an increasing date value, never dates in the past, which makes for easy index appending. Not a big slowdown for the inserts.
Only consider more complex indices if you experience problems with the above.
Regards K
Upvotes: 7