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 -> Need expert help... a challenging query

Need expert help... a challenging query

From: Damon Hastings <damonhastings_at_my-deja.com>
Date: Wed, 15 Dec 1999 21:25:35 GMT
Message-ID: <839108$kv2$1@nnrp1.deja.com>


Quick question... how can I make the query "find all records with foo > x, sort the results by 'bar', and give me only the top 10" as efficient as possible, given that there are millions of records with foo > x?

Do I just build indices for 'foo' and 'bar' and hope for the best? My concern there is that the database might use the 'foo' index to do a very fast retrieval of everything with foo > x, but then waste a bunch of time sorting the entire result set via some n*log(n) sorting routine (possibly using the 'bar' index, but still in n*log(n) time) and then throw away the bottom 99.999% of the results. Am I correct in assuming this is the default algorithm the database would use? If not, then what is the default algorithm (or its time complexity, at least); and if so, then how do I override it with something that won't waste so much time sorting results that will be discarded?

Any help would be much appreciated...

Damon Hastings

Sent via Deja.com http://www.deja.com/
Before you buy. Received on Wed Dec 15 1999 - 15:25:35 CST

Original text of this message

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