Subject | Update with a Sub Select |
---|---|
Author | Robert DiFalco |
Post date | 2003-07-30T18:18:25Z |
Maybe someone can explain this to me.
When I do an UPDATE with a sub SELECT, the Query Plan shows a table
scan.
However, if I change the IN clause to use explicit values (say some
comma delimited integers), it uses my index.
Something like:
UPDATE Foo
SET val=0
WHERE id IN ( 1,2,3,4 );
This shows the query using the index on Foo.id.
UPDATE Foo
SET val=0
WHERE id IN ( SELECT Bar.id FROM Bar );
This shows the query performing a table scan on Foo.
What gives? I'm using IBExpert to determine the Query Plan.
R.
When I do an UPDATE with a sub SELECT, the Query Plan shows a table
scan.
However, if I change the IN clause to use explicit values (say some
comma delimited integers), it uses my index.
Something like:
UPDATE Foo
SET val=0
WHERE id IN ( 1,2,3,4 );
This shows the query using the index on Foo.id.
UPDATE Foo
SET val=0
WHERE id IN ( SELECT Bar.id FROM Bar );
This shows the query performing a table scan on Foo.
What gives? I'm using IBExpert to determine the Query Plan.
R.