
A payment journal with 5 lines can take 20-30 minutes to validate and another 20-30 to post. I believe that I have found the problem code.
In Classes\LedgerJournalTransUpdateCust\checkSettleVoucher we can find the following 'while select':
while select crossCompany Balance01 from specTrans
where specTrans.SpecCompany == _ledgerJournalTrans.company() &&
specTrans.SpecTableId == _ledgerJournalTrans.TableId &&
specTrans.SpecRecId == _ledgerJournalTrans.RecId
join AmountCur from custTransOpen
where specTrans.RefCompany == custTransOpen.DataAreaId &&
specTrans.RefTableId == custTransOpen.TableId &&
specTrans.RefRecId == custTransOpen.RecId
join RecId, Voucher, AccountNum, Approved, Closed from custTrans
where custTransOpen.RefRecId == custTrans.RecId
join Party from custTransCustomer
where custTrans.AccountNum == custTransCustomer.AccountNum
Now if you take away the 'crosscompany' it runs very quick. Also if you take away custTransCustomer (CustTable) the query will run very quickly.
So, I believe this might have to do with the fact that we have our Customers set up under a 'Virtual company' so that they exist in ALL entities.
With that in mind, I'm wondering if there is an '&&' we can append to the custTransCustomer to help speed up the query while maintaining the integrity of query and the validation as a whole.
*This post is locked for comments
I have the same question (0)I think the quickest and possibly best solution here is to remove the join on 'custTransCustomer' and do:
select firstonly Party from custTransCustomer
where custTransCustomer.AccountNum == custTrans.AccountNum
This takes a journal that was validating in 20-30 minutes down to less than 10 seconds.