To find missing indexes in Dynamics 365 Finance and Operations, trace the slow process with Trace Parser, then open its slowest queries in SQL Server’s execution plan. SQL Server shows the missing index and the estimated saving, and you add the index to the table in Visual Studio. The result can be a dramatic speed improvement for complex queries.
No magic, no fluff. Just a clean, repeatable process.
Note: this assumes the query itself is well designed. The trick won’t fix queries that are slow by design.
Find Missing Indexes in Five Steps
1. Analyze the trace collected from the slow part in the system.
2. Copy-paste the time-consuming queries to SQL Server and Run the Display Estimated Execution Plan and let it tell you what index needs to be added.
3. Right click on the index text part and select Missing index details…
4. Here you can see we found a missing index that can save us over 45% of the execution time!
5. Now you can apply the suggested index in Visual studio.
Here I am applying the include on ItemId Qty and VoucherPhysical as suggested by SQL Server.
Before You Add a Missing Index
A missing index suggestion is a strong hint, not an instruction. Before you add it, check these points:
- Test it first. Add the index in a development or sandbox environment with realistic data, then take a new trace and compare the timings.
- Use a table extension. Add the index to a table extension in your own model. Never change Microsoft’s table directly, so the change stays upgrade-safe.
- Check the existing indexes. If an index already starts with the same fields, extending or reusing it is usually better than adding a near-duplicate.
- Count the cost. Every index slows inserts and updates a little. So add only indexes with a clear saving on queries that run often.
- Release it properly. Deploy the index through your normal build and release process, like any other change.
For more on capturing and reading traces, see Microsoft’s guide to Trace parser.
When an Index Won't Help
Sometimes the trace points to a problem that no index can fix. For example:
- The code is slow by design. Selects inside loops, missing joins or fetching every field are code problems. Instead, rewrite the X++ with joins, field lists and set-based operations such as insert_recordset and update_recordset.
- The query returns a lot of data on purpose. An index can’t make a large result set small.
- The time is spent waiting, not reading. Blocking and locking need a different fix, such as shorter transactions.
- The saving is tiny. If SQL Server estimates only a small improvement, the extra index usually isn’t worth it.
Need help with a slow process in your environment? Our Dynamics 365 customization team reviews performance issues and fixes them in upgrade-safe X++.
That’s it for today!
Happy Daxing!
Hichem