Skip to main content

Notifications

Microsoft Dynamics AX (Archived)

How to speed up an X++ SQL Query

Posted on by 200

I am trying to Select the latest SalesLine with a specific serial number.  Here is my query:

Select FirstOnly SalesLine Order By SalesLine.createdDateTime Desc
        Exists Join InventDim Where InventDim.inventDimId == SalesLine.InventDimId
            && InventDim.inventSerialId == "Serial Number";

It is very slow, and I need  a way to increase speed.  Should I add indexes on InventDim.InventSerialId and SalesLine.InventDim?

Thanks.

*This post is locked for comments

  • cowboyott Profile Picture
    cowboyott 200 on at
    RE: How to speed up an X++ SQL Query

    Bingo. I don't know why I didn't order by recId to begin with.  Thanks!

  • cowboyott Profile Picture
    cowboyott 200 on at
    RE: How to speed up an X++ SQL Query

    Thanks Sukrut,

    There may be multiple sales Lines with the same serial (I know this isn't normal, but its possible in our scenario). So, I need the latest salesLine, hence the order by.   I am using the exists join, because I only need the SalesLine info, not the invent dim Info. I thought that would be faster.

  • cowboyott Profile Picture
    cowboyott 200 on at
    RE: How to speed up an X++ SQL Query

    Actually, it looks like both those indexes exist already...

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans