MySQL Forums
Forum List  »  Optimizer & Parser

Re: inner join on range criteria: unable to use index?
Posted by: Rick James
Date: September 26, 2008 11:38PM

Didn't you want an OR somewhere in this?
select * from s inner join r on r.tstart >= s.chrstart and and r.tstart <= s.chrstop and r.tend <= s.chrstop and r.tend >== s.chrstart and r.tname=s.chr and r.strand=s.chrstrand;

Anyway -- Inequalities tend to stop further use of indexes. Do start with = situations (as pointed out by others).

Another solution (though it may not be practical here) is to bucketize the start/end thingies. That is, change the data (and api) to turn the range into... Well, let me give an example: Suppose the ranges are times. The buckets could be hours. Now instead of > and <, say WHERE time_bucket = hr . Further, if it extends beyond one hour, use UNION, not OR. And if that is not precise enough, it still might be good for reducing the number of rows it has to look at. [Sorry if this is not clear enough.]

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: inner join on range criteria: unable to use index?
2981
September 26, 2008 11:38PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.