Microsoft Dynamics NAV has been configured to use the Microsoft SQL Server database engine as efficiently as possible. This includes using SQL queries which are appropriate for parallel query execution to speed up the retrieval of data when the SQL Server is configured to allow this. Parallelism in SQL Server can be controlled using the “max degree of parallelism” (aka MAXDOP) configuration option as explained in this article:
If you enable parallel query execution on SQL Server, complex queries executed by the Microsoft Dynamics NAV application may be broken up into component sub-queries by the SQL Server engine. These sub-queries can run in parallel (each utilizing a different processor), and the results are then combined into a single result set before being returned to the Dynamics NAV middle tier service. On an 8 processor machine, for example, 8 small queries running in parallel will return all of the results faster than a single big query running on a single process doing the same task.
If you set the SQL Server MAXDOP configuration option to any value other than ‘1’ on a multiprocessor machine, then you are allowing the SQL Server query optimizer to use a parallel query execution strategy where it calculates that this will provide a significant performance benefit. Note that MAXDOP=0 by default after you install SQL Server.
The kind of SQL Server queries submitted by the Microsoft Dynamics NAV application can often benefit from parallel query execution. In some scenarios with multiple queries split into many parallel query processes there can be hundreds of query threads competing for resources inside the SQL engine. These SQL Server query threads are known as “Worker Threads” and the maximum number allowed is controlled by another configuration option in SQL Server. You can read more about the “Max Worker Threads” configuration option here:
Normally, the default value for the “Max Worker Threads” SQL Server configuration option is more than enough to cope with whatever Dynamics NAV will throw at it. However, in certain rare scenarios the SQL Server engine can run out of worker threads, especially if the Dynamics NAV middle tier cannot read all of the results being returned to it quickly enough. When this happens the SQL Server instance can become unresponsive until some of the executing threads complete their tasks and can take on some of the pending workload. If you encounter this situation you may see the following error message in the SQL Server errorlog:
All schedulers on Node 0 appear deadlocked due to a large number of worker threads waiting on ASYNC_NETWORK_IO. Process Utilization 0%.
In the unlikely event that you encounter this scenario, we suggest that you connect to SQL Server using the dedicated administrator connection (DAC), and kill the process which is consuming the majority of Worker Threads in order to regain control of the SQL Server instance. Then increase the “Max Worker Threads” configuration option as explained in the article above to avoid future occurrences of the issue.
Microsoft Dynamics NAV Support EMEA