Subject Re: [firebird-support] Better plan for delete statement
Author Martijn Tonies
Hello Christian,

> I have a delete statement like this:
> delete from A where AID in
> (select AID from B where TYP = 3 and PARENTID = 51)
> The two tables are in a 1:1 relationship. On table A and B I have a
> unique index on AID.
> Is there a way, to speed up such a query? In the plan I see, that the
> table A is accessed "NATURAL".

If this is something you need to do regularly, write a stored
procedure that does this (pseudocode):

for each in
select aid from b where typ = 3 and parentid = 51 into :loop_aid
do delete from a where aid = :loop_aid

With regards,

Martijn Tonies
Database Workbench - developer tool for InterBase, Firebird, MySQL & MS SQL
Upscene Productions