Index with two date fields using comparison operators
Hi,
I have a table for storing historical data with two date fields (valid_from, valid_till). I have indexed this two fields with a B-Tree index. If I run a query like this:
select * from subreg where
valid_from = '2011-01-22' and
valid_till = '2011-01-25';
it works fine. If check the explain I can see, that the key length is 6.
If I change the query slightly:
select * from subreg where
valid_from = '2011-01-22' and
valid_till > '2011-01-23';
it's still okay.
But this query takes long time to execute:
select * from subreg where
valid_from < '2011-01-23' and
valid_till > '2011-01-23';
I suppose the index is used only for the first column in this case (at least the length of the key is only 3 in this case). Is there anything I can do to increase the performance of this query?
Subject
Views
Written By
Posted
Index with two date fields using comparison operators
5787
December 05, 2010 05:38PM
1428
December 06, 2010 08:33PM
1089
December 08, 2010 06:04AM
1232
December 08, 2010 06:08AM
1125
December 08, 2010 06:28AM
1434
December 08, 2010 09:09AM
1496
December 08, 2010 09:54AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.