SQL server Performance Issues

  • I am seeing too much of dead locks and PID's blocking their own sessions. Why?

    I did run trace and when I execute the query manually it executes in few seconds. Couple of weeks before all were working fine.

    Any clue as where should I be looking to troubleshoot the problems.

    Thanks in advance for your time!

  • Rajaa, what you are seeing is not strange, heres why

    In SP4 we are able to determine the blocking spid for latch waits when the blocking spid holds the latch in exclusive or update mode. In these cases the blocking spid information is populated into the "blocked" field in sysprocesses.

    So why is the spid blocked by itself? Well, that has to do with how latches are used for IO operations. When an IO is issued for page, a latch is held on the page. Depending on the IO operation, the latch mode acquired is shared (SH) or exclusive (EX). The latch for the IO is acquired by the thread that issues the IO. Since all SQL Server IO operations are asynchronous, if the spid that issued the IO wants to wait for the IO to complete it will attempt to acquire another latch on the same page after issuing the IO. The first latch is released when the IO completes. This release allows the second latch request to be granted.

    Here's an example of how this works:

    1. Spid 55 wants to read page P1 which does not exist in the buffer pool.

    2. Spid 55 acquires an EX latch on page P1 -- this marks spid 55 as owning the latch. The latch is in an in memory data structure, not the physical page itself. Since the page does not yet exist in memory the mode is EX in order to force other spids that may also want to access the page to wait for the IO to complete and also to prevent them from issuing a second IO operation for the same page.

    3. Spid 55 issues the IO request to read P1 from disk.

    4. Since Spid 55 wants to read the page, it must wait for the IO to

    complete. It does this by attempting to acquire another latch (in this case a share (SH)) latch on the page. Since the latch is already held in EX, the SH request is blocked and the spid is suspended.

    5. Upon completion of the IO the EX latch on the page is released.

    6. The release of the EX latch grants the SH latch to spid 55.

    7. Spid 55 can now read the page.

    For the duration between steps 4 (the SH latch acquire) and step 5 (EX latch release) sysprocesses will indicate that spid 55 is blocked by itself with a wait type of PAGEIOLATCH_XX (where XX can be SH, UP, or EX) as an indication that it is waiting for the completion of an IO that it itself issued.

    Refer to this article : http://support.microsoft.com/default.aspx/kb/906344

    Hope this helps

    Thanks!!

    The_SQL_DBA
    MCTS

    "Quality is never an accident; it is always the result of high intention, sincere effort, intelligent direction and skillful execution; it represents the wise choice of many alternatives."

  • Good explanation of the self-blocking processes. Also, for your deadlocks, here's a good link to help :http://qa.sqlservercentral.com/articles/Performance+Tuning+and+Scaling/tracingdeadlocks/1324/

    John Rowan

    ======================================================
    ======================================================
    Forum Etiquette: How to post data/code on a forum to get the best help[/url] - by Jeff Moden

  • Thank you The_SQL_DBA for your elaborate details on the subject. Let me go through this and get back to you.

    Thanks again for your time!

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply