Hello,
does have IN operator in WHERE clausule any "undocumented" slowdown?
I have tables:
CREATE TABLE A (
pkA int NOT NULL
num int
...
);
CREATE TABLE B (
fkA int NOT NULL,
...
);
ALTER TABLE B ADD CONSTRAINT FK_B_fkB_A_pkA FOREIGN KEY (fkB) REFERENCES
A(pkA);
I have 3000 records in A and same number in B. For each record A I
have one record in B.
When I do:
DELETE FROM B WHERE fkB IN (SELECT pkA FROM A WHERE num=1)
postgresql start working for 2-3 minutes. But select (from IN
clausule) SELECT pkA FROM A WHERE num=1 end in few seconds. The slowest
is this DELETE when IN SELECT returns no records.
Does any have some idea whats wrong?
Jirka Novak