Subject Re: [firebird-support] Best table structure for Debit/Credit
Author Matthias Hanft
Vincenzo Scarpellino wrote:

> sum(
> case
> when (b.transtype = 'R') /* reminder */
> and
> (b.transdate + 0 > (select transdate from vlastpay v
> where company=2 and v.custno = b.custno))
> then 1
> else 0
> end
> ) as current_reminders
>
>
> b.transdate + 0.
>
> Tell me how is gone.

Seems to make no difference...

Plan:
PLAN SORT ((V VONLYPAY BILLING INDEX (RDB$FOREIGN16,RDB$FOREIGN16,RDB$FOREIGN16,RDB$FOREIGN16,RDB$FOREIGN16,RDB$FOREIGN16,RDB$FOREIGN16)))
PLAN SORT (JOIN (B INDEX (RDB$FOREIGN15),T INDEX (RDB$PRIMARY1)))
Adapted plan:
PLAN SORT ((V VONLYPAY BUCHUNGEN INDEX (INTEG_54,INTEG_54,INTEG_54,INTEG_54,INTEG_54,INTEG_54,INTEG_54))) PLAN SORT (JOIN (B INDEX (INTEG_47),T INDEX (INTEG_2)))
------ Performance info ------
Prepare time = 31ms
Execute time = 6h 9m 1s 781ms
Avg fetch time = 651.228,85 ms
Current memory = 1.552.512
Max memory = 1.923.260
Memory buffers = 2.048
Reads from disk to cache = 39.938.308
Writes from cache to disk = 84
Fetches from cache = -311.430.838

Matthias