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