Subject Re: plan
Author Svein Erling Tysvær
>I get this plan (using IB_SQL):
>For every additional value in the "IN value list" I get another
>"RDB$PRIMARY5" added to the plan.
>Is this normal behavior ? Could I specify a faster plan with just one
>"RDB$PRIMARY5" ? I tried this but IB_SQL still shows the above plan.

No, this is the best plan Firebird can come up with, using IN is equivalent to a using a lot of ORs. In your example, you may improve speed marginally by changing to

select * from clienten
where id_client between 3768 and 3772
or id_client = 5116

but in general the plan you have should be pretty OK. It is not the written length of a plan that matters, it is its speed and PLAN (CLIENTEN INDEX (RDB$PRIMARY5,RDB$PRIMARY5,RDB$PRIMARY5,RDB$PRIMARY5,RDB$PRIMARY5,RDB$PRIMARY5)) should execute fast.

If your IN clause covers too much of a portion of the potential records, you may get better off by using NATURAL plan and you can force this by changing your query to

select * from clienten
where id_client in (3768,3771,3769,3770,3772,5116) or 2=0

Though assuming your table contains at least 100 records (just choosing a random number considerably higher than 6, I don't know whether the treshold for whether an index is useful or not is 20 or 80 records) and id_client is its primary key, this should be slower than using the index.