Subject Re: [firebird-support] Bad join plan in 2.0.1, why?
Author Alexandre Benson Smith
Jorge Andres Brugger wrote:
> Alexandre:
>
> Thanks for your answer.
>
> Really, what I do later is:
>
> select sum(cantidad) from vw_items_facturas_no_anuladas where sucursal = 1
> and fecha > '2007-04-30' and codigo_producto = 31344
>

What is the plan for this single query ? The one you sent on the first
message ?

Do you have indices defined for:
Items_Factura.Codigo_Producto
Facturas.Fecha
?

If not, define it, I hope it would improve a lot your query.

> (called from inside SP).
>
> It tooks aprox 15 secs for each "codigo_producto", and I've about 35000 ...
> so it takes too much.
>
> Adding a fecha index doesnt make it faster.
>

Strange, what the plan before and after adding that index ? The same ?

> If you have some other suggestion, I'll glad to read them.
>

My suggestion is to add the two indices above, you told me Fecha was
indexed and doesn't help, I think it's strange.

Try to set the indices statistics of all indices on the two tables.

> Regards
>

see you !

--
Alexandre Benson Smith
Development
THOR Software e Comercial Ltda
Santo Andre - Sao Paulo - Brazil
www.thorsoftware.com.br