Subject Re: Very Slow Query
Author svein_erling
Luis,
drop the indexes CLIENTE21 and CLIENTE22. Adding other fields to an index after the primary key is never wise. Depending on whether the field ATIVO have many duplicates or not, you may consider changing XWA_SYS_ATIVO_7DCDAAA2 to indexing (ATIVO, ID_CLIENTE).

I am confused by seeing your plan
> PLAN JOIN (CLIENTE ORDER I_NOME,CLIENTE_MAILING INDEX
> (RDB$FOREIGN28,RDB$PRIMARY5,RDB$FOREIGN29,
>RDB$PRIMARY5,RDBFOREIGN29))

Does the query contain more information you have not told us about (i.e. did you remove some where conditions from your original query)? It simply does not make sense to have that many indexes in the plan for CLIENTE_MAILING for the query you state.

HTH,
Set

> Query Results (800 records):
> Select Cliente.Nome
> From Cliente,Cliente_Mailing Where
> (Cliente_Mailing.id_mailing in(9,8))
> and Cliente.id_cliente=Cliente_Mailing.id_cliente
> Order by nome