Subject Re: [firebird-support] Re: Query speed is going down
Author Bogusław Brandys
Svein Erling Tysvćr wrote:
> Hi Boguslaw!
>
> I doubt you can improve your query much. Logically,
>
> Z.DATASPRZEDAZY BETWEEN '2005-02-01' AND '2005-02-01'
> AND ((Z.GODZINA BETWEEN 8 AND 8) OR Z.GODZINA=0))
>
> belongs in the WHERE clause and not in the JOIN clause, but that's the
> only thing I see that ought to be changed in the SQL and it shouldn't
> help solving your problem, because the plan seems just fine. Though
> wait a minute! Your plan mentions two tables (CM and CT) that are not
> in your query! Why???

Oh..Yes my mistake. That was plan for slighty modified query to limit
TOWARY and MAGAZYNY records and in this case this query has resonable
speed (a couple of seconds)

> You could of course try to remove the GODZINA field from your
> SPRZEDAZ_IDX_DATA index, though my guess is that it would not improve
> the execution speed (though it is worth a try).
>
> I assume adding
>
> 'WHERE P.ILOSC > 0 [AND|OR] (P.CSNETTO > 0)'
>
> will change the result your query?

Yes.But I tried WHERE P.ILOSC<>0 AND P.CSNETTO<>0. No significant speed
up however.

> I must admit that I will be surprised if the speed increases more than
> the range, I can understand that if one day takes 30 seconds, then one
> month will take 15 minutes, but if it increases more than that, then
> I'd say it ought to be investigated.

Well, I'm quite sure now that it's related to big resultset returned for
summarization.Seems no solution other then some kind of aggregation and
normalization of data.

> Sorry for not being able to be of more help,
> Set

Your help is very valuable.Thank You.
Boguslaw Brandys