Can I use an index to get the last n records?

Giganews Newsgroups
Subject: Can I use an index to get the last n records?
Posted by:  Timasmith (timasmi…@hotmail.com)
Date: Mon, 16 Jul 2007

If I have a table with 100,000,000 rows

sales(sales_id, sales_person_id, sales_date_time, ...)

create index sales_date_index on sales (sales_person_id,
sales_date_time);

I want to execute something like this (which doesnt work at all)

select * from sales
where sales_person_id = :sales_person_param
  and rownum < 10
order by sales_date_time desc

I want it to use my sales_date_index to read just 10 indexed records -
NOT read all records for the sales_person_id, sort in memory and then
return me the result set.

Anyway in general I can force traversal of the records using an index?

thanks

Replies