Auser99 <[email protected]> writes: > In Derby, when user Select ... where ... IN (Select ... ), it runs extremely > slow, even though both selects are have optimized indeces (the primary > keys). Can someone suggest a get-around rather than run the queries one at a > time? Thanks.
It's difficult to say without seeing the exact query, but sometimes it may be faster to write the query as a join instead of using an IN subquery. In many cases Derby is able to rewrite the query for you (see [1] and [2]), but it doesn't always detect that there is an equivalent join. [1] http://db.apache.org/derby/docs/10.5/tuning/ctuntransform36368.html [2] http://db.apache.org/derby/docs/10.5/tuning/ctuntransform25868.html -- Knut Anders
