SELECT subquery much slower than IN ( list...)???
Posted in 1998
I have been having problems with a select statement of the type:
select col1, col2
from bigtable
where col1 in
(select key from temp_list_table);
In one case I looked at, the subquery returns just 13 unique values in
subsecond time, yet it took almost 7 minutes for the main query to
complete.
On the other hand, if I write out the result of the subquery explicitly,
such as:
select col1, col2
from bigtable
where col1 in ('A','B','C','D','E','F','G','H','I','J','K','L','M');
the query completes in less than 2 seconds.
I guess I had the mistaken assumption that the main query treated the
subquery result like an explicit list of the form ('val1','val2',...).
What could cause the huge performance difference between the two query
forms?
I am on 7.23 and Solaris 2.5.1, Sun E3000.
--
Matt Reprogle
reprogle@iquest.net