Subject Re: [firebird-support] where Afield in (a subselect) inefficient???
Author Arno Brinkman

> Is the following query very inefficient as the subselect clause run
> as many times as records matched in ?
> SELECT some_fields_in_table_a FROM table_a TA
> WHERE TA.one_indexed_field = some_value
> AND TA.another_indexed_field IN (SELECT pkey FROM table_b);
> I hope the subselect will only run once.

No, the sub-select will be executed for every record inside table_a, but in
a form of :
EXISTS(SELECT pkey FROM table_b WHERE table_b.pkey =
If there is an index available on table_b.pkey (That is so,because that's
the PK :-) that one will be used as you can see in the PLAN.

Arno Brinkman

Firebird links :

Nederlandse firebird nieuwsgroep :