Subject | Re: [firebird-support] Optimizing query |
---|---|
Author | Ann W. Harrison |
Post date | 2010-07-09T20:49:25Z |
Ismael L. Donis GarcĂa wrote:
provide the plan generated by the query. Another is to specify
which version of Firebird you're running, in which architecture,
and on what platform. Another is to specify what indexes you
have defined on the table. Another is to give a rough approximation
of the number of rows in each table, the selectivity of indexes,
and the size of the expected result. And finally, please, could
you format the query?
a.antdebe, a.nota, b.factura, b.fecha, b.debe
from pafacpag a
left join (select c.idedoc as ide, c.factura, c.fecha, c.debe
from pafacpag c
where (((c.entidad)='2578')
and ((c.debe)>0)
and ((c.clave)='PS'))) as b
on a.idedoc = b.ide
where (((a.fecha)<'2009/12/31')
and ((a.debe)>0)
and ((a.entidad)='2578')
and ((a.factura)='PA')
and ((a.clave)='PO'))
order by a.docemp, a.fecha, b.fecha
Best regards,
Ann
> I have the following query, but it takes long.You could do several things to help us help you. One is to
provide the plan generated by the query. Another is to specify
which version of Firebird you're running, in which architecture,
and on what platform. Another is to specify what indexes you
have defined on the table. Another is to give a rough approximation
of the number of rows in each table, the selectivity of indexes,
and the size of the expected result. And finally, please, could
you format the query?
>In the current format, that's unknowable.
> Does any way exist of optimizing response time?
>select a.idedoc, a.documento, a.docemp, a.fecha as fec, a.debe as ded,
> select a.idedoc, a.documento, a.docemp, a.fecha as fec, a.debe as ded, a.antdebe, a.nota, b.factura, b.fecha, b.debe
> from pafacpag a left join (select c.idedoc as ide, c.factura, c.fecha, c.debe from pafacpag c where (((c.entidad)='2578')
> and ((c.debe)>0) and ((c.clave)='PS'))) as b on a.idedoc = b.ide where (((a.fecha)<'2009/12/31') and
> ((a.debe)>0) and ((a.entidad)='2578') and ((a.factura)='PA') and ((a.clave)='PO')) order by a.docemp, a.fecha, b.fecha
>
a.antdebe, a.nota, b.factura, b.fecha, b.debe
from pafacpag a
left join (select c.idedoc as ide, c.factura, c.fecha, c.debe
from pafacpag c
where (((c.entidad)='2578')
and ((c.debe)>0)
and ((c.clave)='PS'))) as b
on a.idedoc = b.ide
where (((a.fecha)<'2009/12/31')
and ((a.debe)>0)
and ((a.entidad)='2578')
and ((a.factura)='PA')
and ((a.clave)='PO'))
order by a.docemp, a.fecha, b.fecha
Best regards,
Ann