Subject | Re: Optimizing a query |
---|---|
Author | josef_gschwendtner |
Post date | 2009-01-09T12:52:21Z |
--- In firebird-support@yahoogroups.com, Svein Erling Tysvaer
<svein.erling.tysvaer@...> wrote:
That is exactly what we did in the past.
Problem is that we have two such nullable parameters and end up with
4 queries. So we try to make code more clear (but perfomance should
be the same).
Regards,
Josef
<svein.erling.tysvaer@...> wrote:
>Thank you for your reply.
> A better way (performance wise) could be:
>
> if (ZU is null) then
> begin
> for
> select KA, sum(ValNet)
> from BU
> where KG = :KeyValue
> group by KA
> into :KA, :SumNet
> do
> suspend;
> end
> else
> begin
> for
> select KA, sum(ValNet)
> from BU
> where KG = :KeyValue and Zu = :ZU
> group by KA
> into :KA, :SumNet
> do
> suspend;
> end;
>
That is exactly what we did in the past.
Problem is that we have two such nullable parameters and end up with
4 queries. So we try to make code more clear (but perfomance should
be the same).
Regards,
Josef