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

Home -> Community -> Usenet -> c.d.o.server -> Can I use an index to get the last n records?

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

From: Timasmith <timasmith_at_hotmail.com>
Date: Mon, 16 Jul 2007 08:00:34 -0700
Message-ID: <1184598034.676069.102000@q75g2000hsh.googlegroups.com>


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 Received on Mon Jul 16 2007 - 10:00:34 CDT

Original text of this message

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