Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Answered

Indexes - must they always have partition as the first column?

Posted on by Microsoft Employee

I'm trying to improve the performance of a form that relies on data in the TransactionLog table. If I create an index using t-sql, I get adequate performance

CREATE NONCLUSTERED INDEX [myIndex] ON [dbo].[TRANSACTIONLOG] (

    [TYPE] ASC,
    [PARTITION] ASC,
    [CREATEDTRANSACTIONID] ASC
)

If I create the index in AX, I get columns in a different order (and an extra column for company), and performance is terrible.

create nonclustered index [I_482TYPETRANID] on [dbo].[TRANSACTIONLOG] (

    [PARTITION] asc,
    [DATAAREAID] asc,
    [TYPE] asc,
    [CREATEDTRANSACTIONID] asc
)

Is there any way to force AX to arrange the index's columns in a particular order?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Indexes - must they always have partition as the first column?

    Does anyone has ever do a job X++ to re-order all the index of all tables in AX ? 
    Since we have only 1 partition and 1 company, all those index automatically containing Partition and DataareaId at first in the index is really bad for the statistics SQL and the performance of many queries could be much better if the indexes was re-order.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Indexes - must they always have partition as the first column?

    Thanks Daniel. It seems very straightforward once I think about it.

  • Verified answer
    Jonathancm Profile Picture
    Jonathancm 416 on at
    RE: Indexes - must they always have partition as the first column?

    Hi Seth,

    As Daniel said, you can add partition, dataareaId and recid within the index definition in AX-AOT, this way you will be able to make your own order of the fields. You cannot get rid of those fields, but you can put them in another order. 

    This is one of the most common performance issues, since most of the implemantations only have less than 10 companies... sometimes only one. Most of the times only one partition. So this cause those indexes to have an utterly poor performance over time. 

    As you know if you does not create an index for a table, AX creates an iunique index in SQL, with Partition, DataAreaId and RecId. 

    Please take a look at this blog post for more information:

    https://daxnigel.wordpress.com/2014/10/18/index-field-order-performance-tuning/

  • Verified answer
    Daniel Weichsel Profile Picture
    Daniel Weichsel 1,655 on at
    RE: Indexes - must they always have partition as the first column?

    Hi Seth,

    You can add the Partition and DataAreaId columns to the index definition in the AOT, and then that order will be respected when synchronized to the database.  You won't be able to leave out the DataAreaId column (since AX will automatically add it back in), but this way you can at least adjust the position of the DataAreaId column in the index.

Helpful resources

Quick Links

Dynamics 365 Community Update – Sep 9th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,246 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,041 Super User 2024 Season 2

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans