Subject RE: [firebird-support] Weird PLAN
Author Leyne, Sean
> very slow query (the one I need to run on the system) :
>
> SELECT
> HD_OCORRENCIAS.NUMERO
> FROM HD_OCORRENCIAS
> INNER JOIN HD_STATUS ON HD_OCORRENCIAS.STATUS =
> HD_STATUS.STAT_ID INNER JOIN ORDEM_SERVICO_DIVISAO ON
> HD_OCORRENCIAS.SISTEMA = ORDEM_SERVICO_DIVISAO.IDDIVISAO INNER
> JOIN HD_PROBLEMAS ON HD_OCORRENCIAS.PROBLEMA =
> HD_PROBLEMAS.PROB_ID INNER JOIN CLIENTES ON
> HD_OCORRENCIAS.IDCLIENTE = CLIENTES.IDCLIENTE WHERE
> (HD_STATUS.STAT_PAINEL = 2)
>
> plan used :
>
> PLAN JOIN (CLIENTES NATURAL, HD_OCORRENCIAS INDEX
> (FK_HD_OCORRENCIAS_CLIENTE), HD_STATUS INDEX (PK_HD_STATUS),
> ORDEM_SERVICO_DIVISAO INDEX (PK_ORDEM_SERVICO_DIVISAO),
> HD_PROBLEMAS INDEX (PK_HD_PROBLEMAS))
>
> executed 7.000ms (full table scan on clientes)

1 - What indexes exist on the tables, particularly the CLIENTES table?

2 - Why are JOINing to the ORDEM_SERVICO_DIVISAO, HD_PROBLEMAS and CLIENTES tables? {They are not referred to in the list of output fields}


Sean