Optimizing Your Aged Accounts Receivables Report
Doing numerous upgrades from an older version of Navison to NAV 2015 and 2013, one common complaint is how slow the reports are running. This is especially true for larger reports liked the Aged Accounts Receivables, Aged Accounts Payables, Inventory Valuation, etc.
The old reports that took a long time, such as the Inventory Valuation report, will still take a long time. It doesn't matter what the version you go to. However, there are some reports that used to be quick, but are slow after the upgrade.
One of these reports is the Aged Accounts Receivables report (Report ID: 10040 - Aged Accounts Receivable).
CAUTION: I'm about to get "programmer". If you want the faster report, just skip down to the bottom and download the object.
Removing the Data Type of Column from the report, we get the following DataItem that the report loops through:
On initial look, the report looks simple enough. There are 3 data items:
Customer - The report loops through the customer record to see which customer we need to calculate the aging for.
Cust. Ledger Entry - For every customer record it finds, it will loop through all of the customer ledger for that customer. For any customer ledger that has a remaining amount, it'll put it into a temporary table.
Integer - This dataitem loops through the same records that are inserted into the temporary table on the Cust. Ledger Entry dataitem and summerizes the information to display in different aging "bucket".
The reason why this report is slow is because when you check the DataItemTableView property on the Cust. Ledger Entry dataitem, you'll see that the report is looping through ALL of the customer ledger for that customer.
This report will run fine if you're A/R aging is small. However, this report will get slower as time progresses with more transactions. Worst, it'll consume all the memory on the server and force you to restart.
The problem becomes real apparent when you have EDI customers that are running hundreds of invoices per day.
The idea of the original A/R aging report is correct. Basically, look at the remaining amount based on the date criteria; if there is a balance, then it goes into calculation.
The problem is that it's not running any type of filters to exclude old transactions that has no relevance in our calculation.
To address the performance problem, here are the main things we will need to do:
Look at only transactions that are marked as Open.
If the report is to be backdated, look into only the history that pertains to the date criteria.
First thing we do is to set the proper DataItemTableView property with the filter to Open.
Then we need to add a new detailed Cust. Ledger Entry dataitem to look at the application history of our A/R transaction:
Basically, we're limiting the reads of the database to only open transactions and the subsequent A/R applications from the Aged as of Date set on the report.
Here are the report objects and the text file for your reference;
Not sure what the developer at Microsoft is thinking when programming this report. Aged Accounts Receivable/Payable is one of the most data intensive reports next to the inventory valuation. Reading through every record just does not make sense.
Yes, it'll work in the short run, but give it a few years and the report will slow to a crawl, which is already experienced by customers upgrading.