Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

Need to include a field in a NAV index and create an ascending index

Posted on by 1,303

NAV 2013 R2 using the current Cumulative update.  I have a very slow custom process I'm running off the Sales Line table and SQL Profiler is recommending that I 'include' a field on one index and create an ascending index on another table.

 

Is there a way to do this with NAV or do I need to manage within SQL? 

*This post is locked for comments

  • Miguel Llorca Profile Picture
    Miguel Llorca User Group Leader on at
    RE: Need to include a field in a NAV index and create an ascending index

    I completely agree with Erik and Daniele.

  • Erik Hougaard Profile Picture
    Erik Hougaard 177 on at
    RE: Need to include a field in a NAV index and create an ascending index

    All keys are both ascending and descending, it is just a matter of deciding the reading order of if. NAV does not support mixing ascending and descending within the same key (index).

    If the suggestion from the SQL Profiler is to add a field at the end of the index, you can just do that. And add the new key on the other table.

    Daniele is correct, that in some cases you have to use SETCURRENTKEY to force NAV to give the correct index hint to SQL otherwise the profiler will just keep suggestion to do what you have already done.

  • Dan Eckhoff Profile Picture
    Dan Eckhoff 1,303 on at
    RE: Need to include a field in a NAV index and create an ascending index

    Daniele,

    I appreciate the response, however, I don't think it's what I'm looking for.  I realize that you can use a NAV index in ascending order, but SQL Profiler was looking for an actual index in ascending order in order to optimize.  I do not see a way to accomplish this in NAV.

    Also, I do not mean to include a field in the index key, rather it needs to be 'included' in the dataset results of the index.  It's an SQL convention which in this case improved performance by 57%.  Again, I do not see a method to 'include' fields not in the index key.

    Best Regads,

    Dan  

  • Daniele Rebussi Profile Picture
    Daniele Rebussi 2,480 on at
    RE: Need to include a field in a NAV index and create an ascending index

    You need to create a new key on the table.

    In the NAV dev. environment open the object explorer -> tables -> view -> keys -> insert a new line with the necessary fields.

    The in your code add a SETCURRENTKEY statement to select the key created.

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!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans