How to kill current queries taking most cpu.

  • Sean Lange (2/11/2015)


    admin 31599 (2/11/2015)


    --Current queries

    SELECT

    r.session_id,

    s.TEXT,

    r.[status],

    r.blocking_session_id,

    r.cpu_time,

    r.total_elapsed_time

    FROM sys.dm_exec_requests r

    CROSS APPLY sys.dm_exec_sql_text(sql_handle) AS s

    Find blocking_session_id or heavy one and then

    kill #

    If using this script very often the next step is go to your desk and get 3 envelopes. :w00t:

    Or URLT.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Sean Lange (2/11/2015)


    admin 31599 (2/11/2015)


    --Current queries

    SELECT

    r.session_id,

    s.TEXT,

    r.[status],

    r.blocking_session_id,

    r.cpu_time,

    r.total_elapsed_time

    FROM sys.dm_exec_requests r

    CROSS APPLY sys.dm_exec_sql_text(sql_handle) AS s

    Find blocking_session_id or heavy one and then

    kill #

    If using this script very often the next step is go to your desk and get 3 envelopes. :w00t:

    OMG!!! LMFAO!!! That's EXACTLY what my response was going to be! My sides hurt from laughing so hard! Good thing I didn't have a mouthful of coffee or I'd need a new laptop right now!

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Jeff Moden (2/11/2015)


    Sean Lange (2/11/2015)


    admin 31599 (2/11/2015)


    --Current queries

    SELECT

    r.session_id,

    s.TEXT,

    r.[status],

    r.blocking_session_id,

    r.cpu_time,

    r.total_elapsed_time

    FROM sys.dm_exec_requests r

    CROSS APPLY sys.dm_exec_sql_text(sql_handle) AS s

    Find blocking_session_id or heavy one and then

    kill #

    If using this script very often the next step is go to your desk and get 3 envelopes. :w00t:

    OMG!!! LMFAO!!! That's EXACTLY what my response was going to be! My sides hurt from laughing so hard! Good thing I didn't have a mouthful of coffee or I'd need a new laptop right now!

    WOOHOO!!!! Glad I snuck in my response before you did. 😀

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/

  • GilaMonster (2/11/2015)


    Sean Lange (2/11/2015)


    admin 31599 (2/11/2015)


    --Current queries

    SELECT

    r.session_id,

    s.TEXT,

    r.[status],

    r.blocking_session_id,

    r.cpu_time,

    r.total_elapsed_time

    FROM sys.dm_exec_requests r

    CROSS APPLY sys.dm_exec_sql_text(sql_handle) AS s

    Find blocking_session_id or heavy one and then

    kill #

    If using this script very often the next step is go to your desk and get 3 envelopes. :w00t:

    Or URLT.

    Pretty much the same but the envelopes gives the next person a little warning about what to expect.

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/

  • What do you mean "get 3 envelopes"?

  • admin 31599 (2/11/2015)


    What do you mean "get 3 envelopes"?

    http://www.design.caltech.edu/erik/Misc/Prepare_3_Envelopes.html

    A fellow had just been hired as the new CEO of a large high tech corporation. The CEO who was stepping down met with him privately and presented him with three numbered envelopes. "Open these if you run up against a problem you don't think you can solve," he said.

    Well, things went along pretty smoothly, but six months later, sales took a downturn and he was really catching a lot of heat. About at his wit's end, he remembered the envelopes. He went to his drawer and took out the first envelope. The message read, "Blame your predecessor."

    The new CEO called a press conference and tactfully laid the blame at the feet of the previous CEO. Satisfied with his comments, the press -- and Wall Street - responded positively, sales began to pick up and the problem was soon behind him.

    About a year later, the company was again experiencing a slight dip in sales, combined with serious product problems. Having learned from his previous experience, the CEO quickly opened the second envelope. The message read, "Reorganize." This he did, and the company quickly rebounded.

    After several consecutive profitable quarters, the company once again fell on difficult times. The CEO went to his office, closed the door and opened the third envelope.

    The message said, "Prepare three envelopes."

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • 🙂 thanks.

  • Thanks all.

    I agree that it's bad idea to let them kill spids.

    But we are not going to give it as it is. We are planning to develop a customized sproc and it will be given only to those chosen users who understand the criticality of it. We had implemented the same for one of client where we were supporting 5000+ servers and this issues used to come quite frequently. It was working fine. We are going to log all those as well.

    Thanks again. 🙂

Viewing 8 posts - 16 through 22 (of 22 total)

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