Subject Re: [firebird-support] Best table structure for Debit/Credit
Author Matthias Hanft
Svein Erling Tysvaer wrote:

> My test was also with a subquery, that is
[...]
> and it executes without problems.

Hmmm... strange. I have to investigate this further...

> Well, you managed to bring Firebird to its knees, though I don't yet
> trust you managed to get Firebird produce incorrect results (that is a
> big no-no and I believe such an error that would receive high priority
> amongst the coders if it could be reproduced in a 'simple' test case).

Ok, I didn't want to blame FB for errors, so I should have rather typed
"the results weren't quite what I had expected" :-)

> Are you sure you selected the transdate for the last payment and not
> only the transdate for *a* payment?

I have one view with "only payments":

CREATE VIEW VONLYPAY
(...same columns as in BILLING itself...)
AS
select * from billing
where TRANSTYPE='E' or TRANSTYPE='K' or TRANSTYPE='S' or TRANSTYPE between '0' and '9'
or TRANSTYPE='U' or TRANSTYPE='T' or TRANSTYPE='W';

and another view "last payment":

CREATE VIEW VLASTPAY(COMPANY, CUSTNO, TRANSDATE)
AS select company,custno,max(transdate) from vonlypay group by company,custno;

If I look into the data of VLASTPAY with IBExpert, the Plan Analyzer
shows that indexes _are_ used, but there is a 1-second delay until
the first data rows appear - that's not much, but if this view is
used 1-million times within the "big" query, it surely can take a
little time...

Matthias