• Erland Sommarskog (10/16/2013)


    dwilliscp (10/16/2013)


    So if you have one SPID, but 700 rows, that means the server is trying to do parallel processing? They all show CXPacket.. So how do I track down whay this is going on? (about twice per week)?

    You and Ellen are completely unrelated, aren'y you? I am just wondering if we are trying to to solve one or two problems here.

    Where do you see 700 rows? CXPacket waits token of a parallel query, where some threads have completed their job and are waiting for some other thread to complete. Typically this happens when the optimizer makes a misestimation on how to partition the data over the threads.

    To see what is going on, the first step is to find which querythe process is running. My own favourite tool is beta_lockinfo, but then again I wrote it. You find it on http://www.sommarskog.se/sqlutil/beta_lockinfo.html. This gives you a snapshot on what is going on in the system, including current query and plan.

    Unrelated ... The following is one of the queries that I use to show what is going on... when the server is not responding, and unlike the worker query, this is the one that showed me the 700 rows with the same SPID (all generated by the same query), and I could not see one that was not CXPACKET..but maybe I should have filtered out the CXPACKET wait types after I noticed the SPID creating all the issues.

    USE master

    GO

    SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED

    SELECT

    er.session_Id AS [Spid]

    , sp.ecid

    , er.start_time

    , DATEDIFF(SS,er.start_time,GETDATE()) as [Age Seconds]

    , sp.nt_username

    , er.status

    , er.wait_type

    , SUBSTRING (qt.text, (er.statement_start_offset/2) + 1,

    ((CASE WHEN er.statement_end_offset = -1

    THEN LEN(CONVERT(NVARCHAR(MAX), qt.text)) * 2

    ELSE er.statement_end_offset

    END - er.statement_start_offset)/2) + 1) AS [Individual Query]

    , qt.text AS [Parent Query]

    , sp.program_name

    , sp.Hostname

    , sp.nt_domain

    FROM sys.dm_exec_requests er

    INNER JOIN sys.sysprocesses sp ON er.session_id = sp.spid

    CROSS APPLY sys.dm_exec_sql_text(er.sql_handle)as qt

    WHERE session_Id > 50

    AND session_Id NOT IN (@@SPID)

    ORDER BY session_Id, ecid