Subject | Index usage in update statement |
---|---|
Author | Marcin Bury |
Post date | 2012-02-10T12:03:24Z |
Hello All
Let's say I have two tables:
TABLE_A
ID_A - primary key
FIELD_A - some field
TABLE_B
ID_B - primary key
ID_A - reference to TABLE_A - indexed
FIELD_B - some field - also indexed
then I'd like to update TABLE_A:
UPDATE TABLE_A
SET FIELD_A = some_value
WHERE ID_A IN (SELECT ID_A FROM TABLE_B FIELD_B = some_condition)
When I prepare the statement, Firebird 2.5.1.26166 returns NATURAL plan
for TABLE_A and proper index usage for TABLE_B
Is it correct or am I missing something?
Is there a way to avoid iterating records in some EXECUTE BLOCK statement?
TIA
Marcin
Let's say I have two tables:
TABLE_A
ID_A - primary key
FIELD_A - some field
TABLE_B
ID_B - primary key
ID_A - reference to TABLE_A - indexed
FIELD_B - some field - also indexed
then I'd like to update TABLE_A:
UPDATE TABLE_A
SET FIELD_A = some_value
WHERE ID_A IN (SELECT ID_A FROM TABLE_B FIELD_B = some_condition)
When I prepare the statement, Firebird 2.5.1.26166 returns NATURAL plan
for TABLE_A and proper index usage for TABLE_B
Is it correct or am I missing something?
Is there a way to avoid iterating records in some EXECUTE BLOCK statement?
TIA
Marcin