db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bryan Pendleton <bpendle...@amberpoint.com>
Subject Re: Filtering using the sort order on two columns
Date Wed, 05 Aug 2009 04:54:05 GMT
>>    SELECT field, text, docfreq    FROM Terms
>>    WHERE field > ?
>>    ORDER BY field ASC, text ASC
>>
>>    SELECT field, text, docfreq    FROM Terms
>>    WHERE (field = ? AND text > ?)
>>    ORDER BY field ASC, text ASC
>>
>> Does each query, separately, use the index as you expect?
> 
> Indeed, both of these queries (even the one with only >) do an index
> scan instead of a table scan. 

Great!

Can you construct a UNION of the two queries, and then ORDER BY the UNION?

And, in that case, does it use the index for both the union-ed subqueries?

thanks,

bryan


Mime
View raw message