Folder Blocking
Last updated 11 November 2020.
Blocking - Performance troubleshooting and profiling for Dynamics NAV | BC and SQL Server
Checks SQL Server in scope for some of most common skewed Best Practices and performance issues.
Valid from SQL Server 2012 onwards. By default all databases in the SQL Server instance are eligible for the several database specific checks, and you may use the optional parameter to narrow these checks to specific databases.
Only a system administrator/local host administrator is able to perform all checks or functions.
This code and information are provided "AS IS" without warranty of any kind, either expressed or implied. Furthermore, the author or Olav Treffurt IT Consulting shall not be liable for any damages you may sustain by using this information, whether direct, indirect, special, incidental or consequential, even if it has been advised of the possibility of such damages.
Performance tuning is the process of analyzing query plans, execution plans, indexes, partitioning, etc. and finding ways to reduce the time a query takes or reduce resource usage by that query. There are 4 events that I found can help you to identify queries that can be performance tuned. They are deadlocks, application aborts, blocking, and long running queries.
Contains the following informational sections:
General
SQL Query | Description | Version | ||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Blocking XEvents |
In the view, you can see detailed information about the records captured by the blocked process session. This view allows you to find the location in the AL source code using the SQL Server data.
For more information, see the Blocking Processes Overview - V8 Search XE - Product Documentation |
2.0 | ||||||||||||||||||||||||||||||||||||
Blocking Application | In the view you get information about how often an application blocked another application. This is NAV/BC interesting, because it is easy to see if third party products are interfering with the day-to-day operations in Dynamics. | 2.0 | ||||||||||||||||||||||||||||||||||||
Blocking Waitresource |
When you’re interpreting the Blocked Process Report – it is important to understand what resources are blocked.
Blocked Waitresource > 30 This view shows all waiting resources that have occurred more than 30 times in the filtered period. From this you can very often recognize that this is a systematic error from the code. In the rarest cases, the event is caused by a manual action of a user. Reading through the Report details , the waitresource indicates the resource needed by the task. Let’s break down the details to understand the resource. Decoding Key and Page WaitResource for Deadlocks and Blocking Here’s a reference on how to decode them. All of this information is out there on the internet already in various places, it’s just spread out! I’m going to pull the whole thing together, from DBCC PAGE to hobt_id to the undocumented %%physloc%% and %%lockres%% functions. First we’ll talk through PAGE lock waits, then we’ll hit the KEY lock waits. 1) waitresource=“PAGE: 6:3:70133 ” = Database_Id : FileId : PageNumberIf your query was waiting on a page level lock, SQL Server gives you the page address. Breaking “PAGE: 6:3:70133” down, we’ve got:
1.1) Decode the database_idFind the database name with this query:
That’s the WideWorldImporters sample database on my SQL Server instance. 1.2) Look up the data file name — if you’re interestedWe’re going to use the data file id in the next step to find the name of the table. You can just move on. But if you’re curious about the name of the data file, you can look it up by using the database and plugging the data file id into this query:
1.3) Get the name of the object from DBCC PAGEWe know this is page # 70133 in data file 3 in the WideWorldImporters database. We can look at that page with the undocumented DBCC PAGE and Trace Flag 3604. Note: I prefer running DBCC page against a restored backup elsewhere, because it’s not supported. In some cases, running DBCC PAGE can cause stack dumps.
Scrolling down in the output, I can find the object_id and IndexId: Whew, almost there! I can now find the table and index name with this query:
And behold, this lock wait was on the PK_Sales_OrderLines index on the Sales.OrderLines table. Note: In SQL Server 2014 and higher, you could also find the object name using the undocumented sys.dm_db_database_page_allocations dynamic management object. But you have to query all the pages in the database, which seems not as awesome against large databases — so I listed the DBCC page method. 1.4) Can I see the data on the page that was locked?Well, yes. But … do you really need to? This is slow even on small tables. But it’s kinda fun, so… since you read this far… let’s talk about %%physloc%%! %%physloc%% is an undocumented piece of magic that will return the physical record locator for every row. You can use %%physloc%% with sys.fn_PhysLocFormatter in SQL Server 2008 and higher. Now that we know that the page lock wait was on Sales.OrderLines, we can see all the data in that table on data file = 3 and page number = 70133 with this query:
Like I said, this is slow even on tiny tables. I’ve added NOLOCK to the query because while we want a glance at this info, we have no guarantee that it’s the way it was earlier when the blocking happened anyway– we’re guessing, so we may as well do dirty reads. But woo hoo, it gives me a clean display of the 25 rows which the query was fighting for: That’s enough detail on waitresource=PAGE.
|
2.0 | ||||||||||||||||||||||||||||||||||||
Blocking Statements |
Returns the text of the SQL batch that is identified by the specified sql_handle.
This query will show you the SQLHandle that was unique in the blocked process report and contains a value other than blank or 0x0. The SQLHandle is a varbinary data type that is suitable for binary data of variable length. The sql_handle is a token that references a stored procedure or a batch. You can be accessed for example via the function "Dashboard -> SQL Server -> SQL Server Check -> Performace | Monitoring -> SQL Handle Short ". |
2.0 | ||||||||||||||||||||||||||||||||||||
Blocking Dashboard |
From version 3 onwards, you have the option of filtering data volumes for display. Before each option, the data filter dialog to include the data display.
Since version 3 of V8 Search XE dashboard and charts are displayed as HTMl pages You can also use these pages outside the application. The files are located in the specified working directory of V8 search XE. The dashboard currently consists of two areas: 1. Tables
|
3.0 | ||||||||||||||||||||||||||||||||||||
Blocking vs Long Duration |
In the view, you can see detailed information about the records captured by the blocked process session. The displayed data are in the long duration range and identified as blocking process.
DESCRIPTION:
This overview contains the most important information to determine the causes of table locks from Dynanamics objects. |
3.0 |