MySQL Forums
Forum List  »  Optimizer & Parser

Will sort help optimizing this query?
Posted by: binglew
Date: June 08, 2006 11:27AM

I encountered the following problem recently. Saying I have two tables (t1, t2), each has thousands of records. The table structure is like this:
t1: ID, From, To, ...
t2: Name, From, To, ...

I want to find the t1.ID and 2.Names which are overlapping. I used the following query:
select t1.ID, t2.Name from t1, t2 where t1.To>=t2.From and t2.To>=t1.From.

Since I have huge tables, this query will take a while. Anybody knows how to optimize it? Thanks a lot!

Binglew

Options: ReplyQuote


Subject
Views
Written By
Posted
Will sort help optimizing this query?
2843
June 08, 2006 11:27AM


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.