Subject Speed up a query with a case insensitive comparation
Author marc_guillot
Hi.

I have this query that runs very slowly :

insert into TR_DIR_POBLACION (POB_ID, POB_POBLACION, POB_OCULTO)
select gen_id(TR_DIR_POBLACION_GEN, 1) * 100 + 1, POBLACION, 1
from (select distinct upper(DIR_POBLACION) as POBLACION
from IMP_CL_DIRECCION
where coalesce(DIR_POBLACION, '') <> '' and
not exists (select *
from TR_DIR_POBLACION
where upper(DIR_POBLACION) =
upper(POB_POBLACION)));

I'm sure the bottleneck is found at : where upper(DIR_POBLACION) =
upper(POB_POBLACION))

I have not indices in this fields, because they will not be used in
this case insenstive comparation.

¿ There is a better way to make a case insensitive comparations that
could use indices ?