Addressing Performance Problem in Dynamics NAV and Dynamics 365 Business Central

Overview

If you’ve recently upgraded to Dynamics NAV 2017 or later versions, you will have undoubtedly noticed that the new version of Dynamics NAV (or Dynamics 365 Business Central) is incredibly slow… It’s so slow that it took one of our customers that’s using NAV 2017 3 minutes and 38 seconds to open a customer card.

Yes, the customer really measured this. And yes, before they upgraded, opening the customer card is instant.

Note that this blog will include Dynamics 365 Business Central as I didn’t see them improving the standard codebase in the release.

EDIT: Microsoft has released a fix in their monthly Cumulative updates to address the performance problem. Ask your NAV partner to implement these hotfixes for you if you’re still encountering issues with poor performance.

Eye Candy

The problem is all the eye candy that Microsoft tries to implement into Dynamics 365 Business Central that caters to the small/micro businesses, or at least make the demo of the product irresistible.

For some odd and strange reason, Microsoft strongly believes the same customers that currently using Dynamics NAV are the same ones that are going to be using Dynamics 365 Business Central.

I’m not sure how we can tell Microsoft that this is not the case. They firmly believe they know the customer better than the channel.

An Example

Let’s take a look customer card in our example and let’s see why it’s so slow. Note that this is one of many screens in the software that has performance problems. I’m just highlighting this page for the purpose of this article.

In order for Microsoft to make Dynamics 365 Business Central look appealing in demo environments and to encourage companies to sign up on first sight, they really have to include all the bells and whistles. And I do mean all the bells and whistles including, but not limited to:

  • Charts and Graphs to display data visually. Why? Because it’s pretty.
  • Factboxes that quickly brings information to you
  • Quick statistics to give you an overview of the data without having to have that extra click
  • Dynamic control on pages – Hiding fields and really dumbing down the user interface
  • Dynamics CRM and Office connection and integration

Let’s take a look a the customer page in the demo environment in Dynamics 365 Business Central:

Looks great right? You have a really quick statistics of how the customer info. And when you navigate around in the demo environment, it’s fast.

Single Codebase

This is the screen if you use the Dynamics NAV (Dynamics 365 Business Central) on any rendition other than from the signup in the Office 365 Admin Console.

If you looked closely, you’ll notice that the Statistics FastTab is missing.

Apparently, in order to keep Dynamics NAV and Dynamics 365 Business Central on the same codebase, Microsoft just hid whatever is not applicable.

Why It’s Slow

There’s a problem with that… When you just hide the control, it doesn’t really prevent the code from running.

If you look at the customer card in the Development Environment, you will see the Statistics FastTab has the Visibility function set to FoundationOnly.

The toggle for setting this is nowhere to be found if you’re not using Dynamics 365 Business Central accessed from Office 365 Admin console.

The problem is the code is written in the worst way possible with no regards for optimization.

It’s doing calculation on massive amounts of data with every time you click on something on the customer card. Good for small datasets (<1000 records), problem if you actually use the software to manage your business.

This means any time a user does something on the page, it’ll run this calculation, over and over and over and over again. Think about your customers that has a 50 GB database, worst, you’ll notice a slowdown with customers running a 1GB database.

The Fix

One would think the simple fix is to just remove the controls from the page. Wrong… The cause of the slowdown is not on the display itself (although the Dynamic Control does slows down performance), it’s the code that’s running in the background.

The code you need to take out is in the triggers of the page.

And here

Removing code on the OnAfterGetRecord and OnAfterGetCurrRecord triggers dramatically improves the performance of the customer card.

Note there are a lot of other things we have to remove from the customer card to make the performance acceptable for the end user. But I will stop here for now.

The Extension Problem

So how do you do this when we’re going into the Extension world? Extensions will NOT allow you to remove base code, so you’re stuck with whatever crap Microsoft stuffs in there. Tested or not.

Looking at the amount of code in the customer page, I’m actually shocked on how all of this got past Quality Control at Microsoft.

Whoever thought it was a good idea to do a lot of rendering and processing at the page level?

You’re asking for performance problems when you’re rendering a large amount of data. This was one of the first thing they taught us at the Navision development class back in 1999; don’t put code on forms/pages.

Conclusion

This article is just focusing on a single page, the customer card. If you look at Sales Order page, another one of the pages that a lot of companies access frequently, it has the same types of problems: too much code on the pages.

Again, a lot of what they stuff in there is nice for demo environment with small datasets. You’ll notice performance problems real quick as your data set increases.

Perhaps this is an opportunity for developers like us to publish an Extension on AppSource. Basically redo NAV pages so people can actually use it.

18 thoughts on “Addressing Performance Problem in Dynamics NAV and Dynamics 365 Business Central

  1. Naveen Jain says:

    Great Article Alex. It does make sense and hopefully Microsoft will consider to do a through testing prior to releasing the new version.

  2. Donna Edwards says:

    How are you writing about an application that is not released until next week and then is released online only? Based on what I know, the below scenario is not possible as the application is not considered GA. It is still in preview. Is the customer referenced in a preview program of sorts and upgraded to the latest preview bits possibly?

    “Yes, the customer really measured this. And yes, before they upgraded, opening the customer card is instant.”

  3. Alex Chow says:

    Simple, the code is written the same way. The screenshot I provided above is from Dynamics 365 Business Central. That statistic tab is a performance time bomb.

    The customer in question for this article is on NAV2017.

  4. Jusa a passenger says:

    NAV2018 – Table “325 VAT Posting Setup” has flow field „Used in Ledger Entries“ what makes hang “472 VAT Posting Setup” page.

  5. Joerg Rau says:

    You have mentioned “Microsoft has released a fix in their monthly Cumulative updates to address the performance problem”. Can you please point out in which CU this has been addressed?

  6. Alex Chow says:

    Just to clarify, there are still other performance issues within the software. I’m working with the product team at Microsoft to get them fixed in future CU releases.

  7. Kasper Dan Jensen says:

    I have adressed major performance issue in the Job Module and have documented these via movieclips to MS and delivered a 50GB customer db.

    Microsoft have restored 4 std. objects in this db and have confirmed that there is a number of performance issues and have created a internal hotfix request for the NAV Development Team to get this fixed.

    Issue is on NAV2017+ and you can follow it via the support case #118070418515979

  8. george says:

    Doesn’t sound OK for me that to create new pages and objects to improve standard product just because Microsoft is not doing that
    Instead is giving us a lot of useless gadgets.
    What about Nav reports ?? Most of them are useless and poorly written, are just an upgraded version of Nav 2009 classic.

  9. xStepa says:

    Hi, even with NAV17 CU23 there are still huge performance issues with rendering – SQL, NSTs are OK, just the clients works very bad … any tips? Rendering takes too long even on empty record (with >300 fields)

  10. Alex Chow says:

    There are a ton of reasons why you may get bad performance. In my personal experience, it’s all related to coding, mainly, removing code from pages so calculations does not occur.

    I would eliminate factboxes and controls systematically to see which one of these calculations is causing the performance issue.

  11. xStepa says:

    as we do some test now – it seems to be caused by too many fields on the page, which exponentiallly decreases the page opening time (switching between the records is then acceptable). Adding 2 times more fields costs 6 times more time to open … no flowfields, just fixed values … on average computer, our customer card opens for 15seconds for example

  12. Alex Chow says:

    If switching between records does not cause performance issue, then I would look into the OnOpen or any triggers that runs only when the page is open. From my experience, having regular fixed fields does not cause performance problem.

  13. xStepa says:

    we removed all code from triggers (on the testing Page) – only fields and tabs remained.
    Also there was noticeable speed increase when used Alt+F12 (or callapsed tabs manually). And it varies on used computer (in seconds – better was SSD and faster/not bigger RAM)

  14. Dave Cintron says:

    It seems the concept of code optimization has disappeared from programmer training. Now that we have terabytes of hard drive space and huge memory allocations, programmers seem to think resources are unlimited. Back in the 80’s I knew a guy who wrote an input routing in 900 BYTES of compiled code. Nevertheless, with the Windows OS running in over a GB of RAM and typical applications loading DLLs that occupy 100’s of MB of RAM, no matter how much processor power we throw in it will get eaten up by unoptimized windows applications. Microsoft only seems to care that once the sale is made, the Customer is on their own.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.