MySQL Forums
Forum List  »  New in 4.1: Subqueries

"Where" condition containing ...in (select ...)
Posted by: Majdi Swais
Date: August 05, 2005 03:26AM

I'm trying to execute the following query
"select f1,f2 from table1 where f2 in (select f3 from table2 where ...)"

This query takes too much time to execute especially when table1 contains thousands of rows. If I execute "select f3 from table2 where ...", store the results in an array (r1,r2,...,rn) and rewrite the query as:
"select f1,f2 from table1 where f2 in (r1,r2,...,rn)", the query will execute very fast (as expected)
Note: both f2 and f3 are integers and indexed

Regards

Options: ReplyQuote


Subject
Views
Written By
Posted
"Where" condition containing ...in (select ...)
4054
August 05, 2005 03:26AM


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.