In brief
Month-end close in an ERP system usually takes hours for several reasons at once: the transactional database holds many years of data, closing operations run one after another in a single thread, heavy reports run on the same database as posting and block each other, and customizations added over the years process data row by row. What helps is measuring each closing operation separately, analyzing database waits and only then fixing: archiving, reports from a replica, indexes and statistics, job order.
What actually happens at month-end close
Month-end close is not a single operation but a series of jobs, many of which read and recalculate the whole month or the entire history. In a typical trading or manufacturing company they are:
| Operation | What it does with the data | Why it can be slow |
|---|---|---|
| Inventory issue valuation | recalculates the cost of every issue under the valuation method | backdated correction documents force recalculation of many months |
| Production cost settlement | allocates costs to orders and products | many links: orders, materials, labor time |
| Depreciation | calculates charges for every fixed asset | usually fast, unless a customization calculates it item by item |
| Foreign currency revaluation | revalues open items at the exchange rate | a large number of open items |
| Accruals and deferrals | creates journal entries from schedules | usually fast |
| Statements and reports | trial balance, cost analyses, management reports | they read whole tables, often while posting is under way |
| Tax files and exports | collect documents for the period, for example JPK, Poland's standard audit file for tax | large queries on document tables |
Each of these operations alone might take a few minutes. The problem appears when several take an hour, run one after another, and people launch reports at the same time.
Five common causes
- Volume. After a few years an ERP database holds millions of document lines. Queries that read thousands of rows at go-live now read millions, because nobody limited them to the period or an index on the date is missing.
- Reports on the transactional database. A heavy report that reads a whole year, running at the same time as inventory valuation, competes for disk and memory, and sometimes for locks. Both operations slow down.
- Locks. A closing operation locks tables or row ranges while it recalculates. Other users and integrations wait, and their transactions in turn block others. In the database this shows up as long blocking chains.
- Customizations that process row by row. A procedure added a few years ago opens a cursor over all documents of the month and runs several queries for each. With a hundred documents that takes seconds; with a hundred thousand it takes hours.
- Stale statistics and fragmentation. The database optimizer picks a query plan based on statistics. After a large import, or at month-end when tables grow quickly, statistics can be out of date and the database chooses a bad plan.
Infrastructure adds to this: a database virtual machine with shared storage that also handles backups at night can stretch every one of these operations.
How to measure it before changing anything
Instead of guessing, collect data at the next close:
- A close timeline. Start and end of each operation, who launched it, what ran in parallel. It often turns out that three operations take most of the time.
- Database waits. Database engines show what sessions are waiting for: disk, locks, memory, network. In SQL Server the wait statistics view does this, in PostgreSQL the activity and lock views.
- The heaviest queries during the close, with execution plans. How to read plans is covered in SQL query performance and execution plans.
- Blocking chains: which session blocks which and for how long.
- Server resources: CPU, memory and disk queue over the same period.
This data lets you answer whether the problem is one customization, reports launched at the wrong moment or simply storage that is too slow. Typical database bottlenecks are covered in Database bottlenecks.
What usually shortens the close
| Problem | Fix | Watch out for |
|---|---|---|
| Many years of volume in one database | archiving closed years using the ERP vendor's procedure | document retention requirements and access for auditors |
| Reports during posting | reports from a database replica or a data warehouse | data delay in the replica |
| Locks between operations | job order, separate windows for reports and integrations | integrations that run around the clock |
| Row-by-row customizations | rewriting them as set-based SQL operations | testing results on a copy of production |
| Stale statistics | updating statistics after large imports and before the close | the update itself takes time on large tables |
| Missing indexes | indexes on columns used in closing filters | write cost for every new index |
Management reports that load the ERP today are often better moved to a separate analytical database, as covered in A data warehouse for a mid-sized company.
A performance test of the close before a change
Every ERP change that touches the close deserves a test: a version upgrade, a new customization, moving the database to another server or to the cloud, adding a new subsidiary with its volume. The test runs on a copy of the production database with data from the last close. You run the same operations in the same order while reproducing typical user and integration traffic in parallel. The result is compared with the production timeline.
The close also has a process side: missing invoices, mismatched balances, manual reconciliations. That part is covered in A faster month-end close. At B2Bnetwork, performance testing also covers batch operations and reports, not just user screens.
Questions and answers
Will a more powerful server fix a long close?
Sometimes, if the bottleneck is disk or memory. When the cause is locks, row-by-row customizations or a bad query plan, a stronger server shortens the time only slightly, while per-core database license costs may grow. Measure first, then decide on hardware.
Can ERP data be archived without losing history?
Yes, if you use the procedure provided by the system vendor and meet document retention obligations. Data from closed years goes to an archive or a separate database from which it can be read during an audit. Agree the scope with accounting and the auditor before archiving.
Why was the close fast after go-live and takes hours now?
Most often because of data growth and customizations added in later years. Queries and procedures that ran fast at low volume were never tested at today's volume. A close timeline usually shows quickly which operations have grown the most.
Can reports run during the close?
Light ones yes, heavy ones better not. Reports that read a whole year compete with closing operations for disk and locks. The simplest fix is to move them to a database replica or a data warehouse, or to set a window in which they do not run alongside inventory valuation and cost settlement.