Subject Re: [firebird-support] Desactivate usage of a poor selectivity index created by foreign key
Author Jerome Bouvattier
Hello Philippe,

> Hello,
> when we create foreign key an index is created, but this index can have a
> very
> weak selectivity and then the plan is not very good
> for example :
> in this example the field STATUS has only 3 différents values
>
[..]
>
> I know that if I make :
> SELECT * FROM MACHINS WHERE STATUS=1;
> the plan is :
> PLAN (MACHINS INDEX (IDX_FK_STATUS))
>
> and when I make :
> SELECT * FROM MACHINS WHERE STATUS+0=1;
> the plan is (and it is better) :
> PLAN (MACHINS NATURAL)
>
> Is there another way ?

I believe the only way so far, is to drop the FK (along with the index) and
do referential integrity related stuff ourselves in triggers.

Can anyone confirm ?

Also, does anyone know whether the following enhancements are planned for
future FB versions ?

- Creating an FK that uses a preexisting index (which could be a compound
one in order to be more selective)
- Creating an FK without any index at all.

Regards.

--
Jerome