db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Knut Anders Hatlen <Knut.Hat...@Sun.COM>
Subject Re: Select ... where ... IN (Select ... )
Date Wed, 17 Feb 2010 23:10:26 GMT
Auser99 <guser999000@gmail.com> 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

[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

View raw message