2007-11-07

Valid time tables

I do not get it, seems like everything should be quite the contrary.


Quoting the same Dave Ensor and Jan Stevenson. "Oracle Design"


















producte_codeDATE_FROMDATE_TOPrice
113.01.200701.02.20071.12
102.02.200731.10.20072.24
101.11.200701.01.30005.47


select price from prices
where sysdate between date_from and date_to

It seems to be efficient to use index for the columns (PRODUCT_CODE, DATE_TO) since search parameter is located near the upper index bounds. However, note that on query processing still each line which has DATE_TO value grater than SYSDATE will be read. In other words, the optimizer will continue lines reading after we found the required string.

Maximum efficiency is achieved witр recent prices selecting, if column DATE_TO is indexed, and with oldest prices selecting, if DATE_FROM is indexed

No comments:

Post a Comment