Subject Re: [firebird-support] Stange Query Plan
Author Ann W. Harrison
Leonardo Cosmai wrote:
>
> Hi, i have strange results (in performace) for this query:
>
> SELECT ...
> FROM
> PRN00
> INNER JOIN PRN10
> ON (PRN00.PRN0CDAG = PRN10.PRN0CDAG
> AND PRN00.PRN0ANNF = PRN10.PRN0ANNF
> AND PRN00.PRN0RGNR = PRN10.PRN0RGNR)
> INNER JOIN PRN20
> ON (PRN20.PRN0CDAG = PRN00.PRN0CDAG
> AND PRN20.PRN0ANNF = PRN00.PRN0ANNF
> AND PRN20.PRN0RGNR = PRN00.PRN0RGNR)
> INNER JOIN PRN30
> ON (PRN20.PRN2PRDT = PRN30.PRN2PRDT
> AND PRN20.PRN0RGNR = PRN30.PRN0RGNR
> AND PRN20.PRN0ANNF = PRN30.PRN0ANNF
> AND PRN20.PRN0CDAG = PRN30.PRN0CDAG)
> INNER JOIN ART00
> ON (PRN30.PRN3ARTC = ART00.ART0CODE)
> INNER JOIN ANA00
> ON (ANA00.ANA0CODE = PRN10.PRN1CLIE AND ANA00.ANA0TREC=1)
> remember this --> ^^^^^^^^^^^^^^^^
>

Hmm.. The first thing I'd try is moving the last condition -
ANA00.ANA0TREC=1 - to a WHERE clause. That may give the optimizer the
clue it needs. If that doesn't work, I'd hobble that condition by
changing it to ( ANA00.ANA0TREC=1 or 'A' = 'B' ). The optimizer won't
try to use the OR condition.

Regards,


Ann