Engineering
Dynamics 365 Finance & Operations performance optimization
We find out where time is really spent in your Dynamics 365 Finance & Operations environment — in X++, in SQL, in batch scheduling or in integrations — and remove the bottlenecks with targeted, measurable changes.
Performance in action
From Slow ERP Processes to Optimized Performance
Explore how Codefine identifies bottlenecks, analyzes inefficient operations and improves Dynamics 365 Finance & Operations performance.
-
Dynamics 365 Finance & Operations · Batch job
Sales order import
- Workload
- 5,000 records
- Status
- Executing
- Elapsed
- 6:51 of ~18:00
Still running — the warehouse is waiting for these orders.
Scene 1 of 8
A slow Dynamics 365 process
An order administrator starts the nightly sales order import — 5,000 records. The progress bar barely moves; the job takes around 18:00 minutes (illustrative baseline) and blocks the work that depends on it.
-
Batch job history · production
Run Records Duration Night 1 5,000 18:04 Night 2 5,000 17:51 Night 3 5,000 18:12 Where the time goes · trace on sandbox copy
Waiting on database round trips · 89% X++ business logic · 11%
Production (read-only insight)
- Batch job history and task durations
- LCS environment monitoring · SQL insights
- Application Insights telemetry, where enabled
Development / sandbox
- Trace capture + Trace Parser
- X++ debugger and query plans
- Repeatable test with the same data volume
Scene 2 of 8
Codefine investigates
A performance engineer starts from facts: batch job history and telemetry from production, then a trace of the same job on a sandbox copy. Most of the time is spent waiting on database round trips, not in business logic.
-
CustTable::find()InventTable::find()select firstonly PriceDiscTableinsert()one row
- 4 round trips per record
- × 5,000 records
- = 20,000 round trips ≈ 16:00 min waiting
Scene 3 of 8
Find the bottleneck
The trace shows the pattern: for every record, the job runs three separate look-ups and one insert. 5,000 records × 4 = 20,000 round trips, each small, together most of the run time.
-
Before · row by row
while select staging where staging.Status == CFImportStatus::New { CustTable cust = CustTable::find(staging.CustAccount); InventTable item = InventTable::find(staging.ItemId); PriceDiscTable price; select firstonly price where price.ItemRelation == staging.ItemId && price.AccountRelation == cust.PriceGroup; this.createLine(staging, cust, item, price); // insert per row }4 database round trips per record
After · joined read, cache, batched insert
RecordInsertList lines = new RecordInsertList(tableNum(CFSalesImportLine)); while select staging where staging.Status == CFImportStatus::New join cust where cust.AccountNum == staging.CustAccount join item where item.ItemId == staging.ItemId { PriceDiscTable price = this.cachedPrice(staging.ItemId, cust.PriceGroup); lines.add(this.buildLine(staging, cust, item, price)); } lines.insertDatabase(); // batched round trips≈ 0.25 round trips per record (illustrative)
- CustTable::find
- InventTable::find
- PriceDiscTable select
- insert()
- One joined read · cached prices · batched inserts
insert_recordset/update_recordsetwould cut round trips further, but only where table events,insert()overrides and validation allow set-based processing — otherwise the framework falls back to row by row.Scene 4 of 8
Analyse the X++ implementation
The loop reads customer, item and price one row at a time. The revised version reads staging, customer and item in one joined query, caches prices that repeat, and inserts lines in batches. Set-based operations are used only where events, validation and business logic allow it.
-
- 1 Code review Data-access pattern, joins, cache keys and transaction scope reviewed
- 2 Build Compiled in the development environment; supporting index added in the application model, not in SQL
- 3 Test Unit and functional tests in a sandbox: same lines, prices and totals as before
- 4 Benchmark Same 5,000-record workload: 18:00 → 3:00 (illustrative)
- 5 Package Deployable package with the change and its tests
- 6 Deploy Released to production through Microsoft's supported deployment process in an agreed window
- No direct edits to Microsoft-hosted production databases or SQL Server settings — every change travels as code through the same tested pipeline.
Scene 5 of 8
Apply and validate
The change is reviewed, built and tested in development and sandbox environments, benchmarked against the same workload, and released as a deployable package through Microsoft's supported deployment process — no direct changes to the production database.
-
Run Before, then After, then Compare Results. Accelerated time — 120× faster than real time.
Performance lab · sales order import, 5,000 records
Illustrative performance demonstration — not a measured customer benchmark.
Before optimisation Completed (simulated)
Row-by-row: three look-ups and one insert per record
- Elapsed
- 18:00
- Records
- 5,000 / 5,000
- Database calls
- 20,000
After optimisation Completed (simulated)
Joined read, cached prices, batched inserts (RecordInsertList)
- Elapsed
- 3:00
- Records
- 5,000 / 5,000
- Database calls
- 1,250
Comparison for the same 5,000-record workload (illustrative) Metric Before After Change Processing duration 18:00 min 3:00 min −83.3% Database calls 20,000 1,250 −93.75% Records processed 5,000 5,000 Same workload Throughput 278 records/min 1,667 records/min 6× faster Model: duration = database calls × 48 ms + records × 24 ms of X++ logic. Before, database round trips are 89% of the time; the X++ logic itself is unchanged.
Scene 6 of 8
Before vs after — try it
Run both versions in the lab. The simulation replays the illustrative model in accelerated time: the same workload, far fewer database calls, a much shorter run.
-
Nightly sales order import · duration per run (illustrative)
Baseline 3:00 ± 15% failed 1 2 3 4 5 6 7 8 9 10 11 12 13 14 - Consistent execution Every run inside the agreed baseline band.
- Failed-job detection Run 9 failed on a locked record; an alert was raised and the rerun succeeded.
- Regression watch A run drifting above the band after a code, data or configuration change is investigated before users feel it.
- Stable operation Duration, volume and failures are reviewed with the client each month.
Scene 7 of 8
Continuous monitoring
After go-live the job is measured every night against its new baseline. A failed run raises an alert; a duration drifting above the band points to a regression after a code, data-volume or configuration change.
-
Dynamics 365 Finance & Operations · Batch job
Sales order import
- Workload
- 5,000 records
- Status
- Ended
- Duration
- 3:00
Batch completed successfully · 5,000 records · 3:00 (illustrative)
Better Performance. Better Business Operations.
Codefine helps organizations diagnose bottlenecks, optimize X++ and data access, and improve the reliability of Dynamics 365 Finance & Operations.
Scene 8 of 8
A faster business experience
The same import now finishes while the administrator gets a coffee. The orders are ready when the warehouse needs them.
The challenge
“The system is slow” is a symptom, not a diagnosis
Performance complaints in D365 F&O usually arrive as a feeling — posting takes forever, the warehouse waits for a screen, the overnight batch runs into the morning. The causes are rarely one thing. A missing index, an X++ loop that issues a query per record, a data entity processed row by row, a batch group that serialises work, or simply years of data that were never cleaned up.
Codefine treats performance as an engineering investigation. We measure first, identify the dominant cost, change one thing at a time and verify the effect in a production-like environment — so improvements are real and you know why they worked.
Capabilities
What we cover in Performance Optimization
- 01
SQL query analysis
Expensive and frequently executed queries, query plans, missing or unused indexes, parameter-sensitive plans and statistics.
- 02
X++ code review
Row-by-row loops, repeated queries inside loops, missing set-based operations, incorrect caching and heavy display methods.
- 03
Batch performance
Batch group and thread configuration, task bundling, scheduling conflicts and jobs that block each other in the same window.
- 04
Forms & user experience
Slow form opening and grid loading, excessive data sources, non-indexed ranges and heavy calculations on every record.
- 05
Reports & integrations
Report data providers, data entity throughput, recurring integration batching and synchronous calls that should be asynchronous.
- 06
Locking & data volume
Blocking chains, long transactions, growth of transactional and staging tables, and cleanup or archiving routines.
How the engagement works
A clear sequence, agreed up front
-
Define scenarios
Agree the business scenarios that are slow, how slow is too slow, and where they can be reproduced.
-
Measure
Capture traces, query statistics and batch history to build a baseline and see where time goes.
-
Fix
Implement targeted changes — code, indexes, configuration, batch design — one at a time.
-
Verify
Re-measure against the baseline in a production-like environment and document the outcome.
Technical approach
Our approach to Performance Optimization
Measure before changing anything
Optimising without a baseline produces opinions, not results. For each scenario we record what the user does, how long it takes, how often it happens and under which load. That turns “slow” into a number we can improve and verify.
Follow the execution path
A slow posting can spend its time in X++ business logic, in a few expensive SQL statements, waiting on a lock held by a batch job, or calling an external service synchronously. Traces and query statistics show which one dominates. We fix the largest cost first, then measure again.
Common patterns we remove
- Queries executed inside
while selectloops instead of joins or set-based operations insert_recordset,update_recordsetandRecordInsertListnot used where they apply- Display methods doing heavy work for every visible row
- Batch jobs bundled into one task, or competing for the same tables in the same window
- Indexes that do not match the ranges and sorts the application actually uses
- Staging, log and history tables that grow without cleanup
Keep it fast
After the fixes, we leave behind what keeps performance from regressing: cleanup jobs, batch scheduling rules, coding guidelines for the patterns we found and the scenarios worth re-checking after each release.
Benefits
What changes for your organisation
-
Faster daily work
Users spend less time waiting for forms, postings and reports.
-
Shorter batch windows
Overnight and period-end processing finishes in the time available.
-
Lower risk at peaks
Month-end, year-end and seasonal peaks stop being performance emergencies.
-
Knowledge you keep
Every fix comes with the reason it works, so your team can avoid the same pattern later.
FAQ
Questions about Performance Optimization
What D365 F&O performance issues can you analyse?
Slow forms and grids, long-running batch jobs, report delays, SQL query behaviour and blocking, integration and data entity throughput, X++ execution paths and data-volume growth.
Is performance optimization only database tuning?
No. Database work matters, but many problems originate in X++ logic, batch design, configuration or integration patterns. We look at the whole execution path before deciding where to change something.
How do you analyse performance without direct access to the production database?
D365 F&O production runs on Azure SQL managed by Microsoft. We work with the platform's monitoring and query history, traces captured in production-like sandboxes, batch history and telemetry, and reproduce problems in an environment where we can measure safely.
Can you implement the recommendations too?
Yes. We implement X++ changes, index and query changes, batch adjustments and cleanup routines, and verify each against the baseline.
Related services
Often combined with
Discuss Performance Optimization with Codefine
Describe the situation in a few lines — what you run, what is not working and what has to happen next. We reply with concrete questions and a suggested first step.