Function Fn_PageResCracker Internals | John Morehouse
In a previous blog post, I discussed two new methods in SQL Server 2019 to determine exactly which page a request might be waiting for when there is contention. One of these new methods involves a new function, fn_pagerescracker. Naturally, I wanted to see how this function operates. Let's look at the Master database to investigate how it works! The function consumes a BINARY(8) parameter and returns a table. This parameter represents a hexadecimal value that is constructed from the database ID, page ID, and file ID. [crayon-5cc22b68a0c9f403158820/] You can see from the code that the parameter is then "diced" up with SUBSTRING commands and then converted into a small binary value. Also, using SUBSTRING against a binary value (which is the parameter that is passed in) will return the number of bytes specified rather than the number of characters. In this case, the Page ID is the first 4 bytes, the file ID is the following 2 bytes and finally the last 2 bytes represents the