Subject Re: [firebird-support] Query optimization
Author Helen Borrie
At 01:04 PM 2/07/2003 +0200, you wrote:
>Anyone got any ideas on how to optimize this query? It runs for three or
>four minutes, and there are only a few thousand records :
>
> FOR SELECT

[snip]


> GROUP BY l.Receipt, l.Receipt2, l.Acc_Num, l.Sub_Code,
> l.inv_type, l.inv_prefix, c.SurName, s.Sub_Name, s.Card_Code,
> s.RegNum
> ORDER BY c.Surname, l.Acc_Num, l.Sub_Code
>
>
>The query plan :
>
>PLAN SORT (SORT (MERGE (SORT (S NATURAL),SORT (JOIN (C NATURAL,L INDEX
>(IDX_POSTYPE))))))
>
>And the indices : (No indices on subsidiary tables)

Tim,
Forgive all the snipping but first things first. :-))

You say there are no indices on subsidiary tables. Are there any keys?

What are you doing with a mega-grouped + ordered set in a FOR loop?

How many possible POSTYPEs are there?
How many possible POS_IDs?
What is the purpose of all those indices you have in the Log table?
Do you have any other indices on that table? (such as acc_num and sub_code?)

heLen