Subject subselect in update : how to force a plan ?
Author Evelyne Girard
Hi,

I'm trying to run an update on a table like this :

update examen e set e.protocole='C'
where e.id_visite in (select id_visite FROM Patient
left join Visite on (Patient.ID_Patient = Visite.ID_Patient)
WHERE Patient.ID_Patient = '45691')

Statement Plan
--------------
PLAN JOIN (PATIENT INDEX (PK_PATIENT),VISITE INDEX (FK_VISITE_ID_PATIENT))
PLAN (E NATURAL)

But firebird doesn't use the index on examen.id_visite whereas this query
does.

update examen e
set e.protocole = 'C'
where e.id_visite in (8,10,10546)

Statement Plan
--------------
PLAN (E INDEX (FK_EXAMEN_ID_VISITE,FK_EXAMEN_ID_VISITE,FK_EXAMEN_ID_VISITE))

Is there a way to do this update with one SQL statement or must I execute
the select and then execute the update for each row returned by my first
query ??

Thank you

Evelyne