As I had an issue with performance I wanted to create indexes without DATAREAID in Dynamics AX 2009.
The indexes didn’t have the DATAAREAID column which is automatically added to the index as the first column on creation.
Because the new created indexes shouldn’t have this column on the first position I had a problem.
The second problem is that every time an update or synchronization takes place in Dynamics AX 2009 the database objects which are not part of the software architecture are removed.
I came up with two solutions:
- Manually place the DATAAREAID column at the end of the index
- Create a job that checks if the indexes still exist on the database in the database
I chose option 2 because of several reasons:
- I don’t know the impact of the index change ( the index already existed but with the DATAAREAID column)
- I want to be sure the queries benefit the new index for sure
- AX 2009 doesn’t support included columns
The last reason was the the decisive reason why the indexes weren’t created in AX 2009.
The indexes I wanted to create used included columns which apparently isn’t supported in AX 2009.
I created a job in SQL Server with the following code:
USE [<DATABASE NAME>] IF NOT EXISTS ( SELECT name FROM sysindexes WHERE name = '<INDEX NAME>' ) BEGIN <INDEX CODE> END GO
The looks all very simple and it is!
In the new version, AX 2012, included columns are supported so maybe I have to adjust the solution until then.