Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Using Index to find row near value

Using Index to find row near value

From: Björn Wächter <bwc_at_p3-solutionsKILL_SPAM.de>
Date: Tue, 13 Mar 2007 08:38:14 +0100
Message-ID: <55n2n7F25d3pjU1@mid.dfncis.de>


Hi all,

I have a table with a TIMESTAMP column. Now I try to search the row where the TIMESTAMP of the row is less than a given value and the next TIMESTAMP in the table is greater than the given value. I can find this row with this query:

SELECT
*
FROM
(
SELECT
TS_START,
LEAD(TS_START) OVER (ORDER BY TS_START) NEXT_TS_START FROM
TAB_TIME
)
WHERE
TS_START <= TO_TIMESTAMP('05.10.2006 14:24:35','DD.MM.YYYY HH24:MI:SS') AND NEXT_TS_START >= TO_TIMESTAMP('05.10.2006 14:24:35','DD.MM.YYYY HH24:MI:SS') But this results always in a full table scan. Is there a way I can get oracle to use the index in the TIMESTAMP column? I don't know that much about indexes but I think this should be possible.

Thanks Björn Received on Tue Mar 13 2007 - 02:38:14 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US