Subject | Re: [firebird-support] Query too slow |
---|---|
Author | Ann W. Harrison |
Post date | 2008-11-05T17:43:31Z |
Alex Castillo wrote:
NOT EXISTS. The result is that NOT IN can not use indexes that
NOT EXISTS can.
Good luck,
Ann
>There is a subtle difference in NULL handling between NOT IN and
> SELECT ....
> WHERE i.CLAVEUNICA NOT IN (
> SELECT DISTINCT d.CLAVEUNICA
> FROM DOCUMENTOSALIDA doc
> JOIN DETALLECONTRATOSALIDA d ON DOC.IDDOCUMENTOSALIDA=D.IDDOCUMENTOSALIDA
> WHERE doc.TIPOSALIDA <> 'T'
> )
> AND (i.SALDOINICIAL + i.ENTRADAS - i.SALIDAS)= 0
>
> I've solved the slowness using a NOT EXISTS clause, but I wanted to tell you experts in order to analize the "why".
>
NOT EXISTS. The result is that NOT IN can not use indexes that
NOT EXISTS can.
Good luck,
Ann