web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

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

(0) ShareShare
ReportReport
Posted on by 1,305

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

I have the same question (0)
  • Daniele Rebussi Profile Picture
    2,480 on at

    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.

  • Dan Eckhoff Profile Picture
    1,305 on at

    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  

  • Erik Hougaard Profile Picture
    177 on at

    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.

  • Miguel Llorca Gómez Profile Picture
    7,019 User Group Leader on at

    I completely agree with Erik and Daniele.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

#1
HoangNam Profile Picture

HoangNam 7

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans