Subject RE: [firebird-support] Help with a DELETE command
Author Mauricio I Magni
Hello

> I know the above is illegal, but it captures the query I would like to
> delete with. I tried the following but for some reason it locked up the
> database completely -- not even an error message:
>
> DELETE
> FROM Child
> WHERE Child.F_ID
> IN (SELECT Parent.F_CHILD_ID FROM Parent WHERE
> Parent.F_FOO = 1);
>

I recently had a similar problem. The engine doesn't produce a good
execution plan for this kind of query.

The solution was write a store procedure, with a
For select Parent.F_Child_ID from Parent Where Parent.F_Foo = 1
Into :Parent_ID do
Begin
Delete from child where F_ID = :Parent_ID;
End

I think this is not the best solution, but it will improve the speed of
execution a lot.

Mauricio Magni