I would think the following two queries should be processed the same, but the first one takes over a second, while the second takes a few milliseconds.
SELECT * FROM tblData WHERE idA IN (SELECT idB FROM tblIndex WHERE idC=1234);
SELECT * FROM tblData WHERE idA = (SELECT idB FROM tblIndex WHERE idC=1234);
idA is primary key and unique.
idB is foreign key ref. idA.
idC is primary key and unique.
tblData has about 30000 records, tblIndex has about 5000 records..
The (SELECT idB...) always returns a singleton since idC is primary key, so they should be the same, right?
Why does IN take so long ?
Running IB 6.0.2.0 on Win2000.
All ideas much appreciated.
</Anders>
SELECT * FROM tblData WHERE idA IN (SELECT idB FROM tblIndex WHERE idC=1234);
SELECT * FROM tblData WHERE idA = (SELECT idB FROM tblIndex WHERE idC=1234);
idA is primary key and unique.
idB is foreign key ref. idA.
idC is primary key and unique.
tblData has about 30000 records, tblIndex has about 5000 records..
The (SELECT idB...) always returns a singleton since idC is primary key, so they should be the same, right?
Why does IN take so long ?
Running IB 6.0.2.0 on Win2000.
All ideas much appreciated.
</Anders>