Killing Statistics

  • Comments posted to this topic are about the item Killing Statistics

  • Good question and something worth learning

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • Nice question, thanks.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • Learn new thing, thanks

  • Thanks for the question Steve, I learnt something today 🙂

    M&M

  • Glad to learn that but why would you have to run that?

    Even if by some accident you unintentionnally started update stats with fullscan on a 2 TB table, you could still kill your spid to stop it.

    I'm curious, has anybody ever needed to do that?

  • Good question.

    One pedantic niggle about the explanation: KILL STATS JOB doesn't take a job id from the system view, it takes a job id you give it as a parameter, so you have to get it from the system view yourself.

    Tom

  • Ninja's_RGR'us (4/29/2011)


    Glad to learn that but why would you have to run that?

    Even if by some accident you unintentionnally started update stats with fullscan on a 2 TB table, you could still kill your spid to stop it.

    But if it's an asynchronous job it's not running in your spid - how to you find the spid for it?

    I'm curious, has anybody ever needed to do that?

    Not me, for sure.

    Tom

  • Tom.Thomson (4/29/2011)


    Ninja's_RGR'us (4/29/2011)


    Glad to learn that but why would you have to run that?

    Even if by some accident you unintentionnally started update stats with fullscan on a 2 TB table, you could still kill your spid to stop it.

    But if it's an asynchronous job it's not running in your spid - how to you find the spid for it?

    I'm curious, has anybody ever needed to do that?

    Not me, for sure.

    What's hard to wrap my mind around is the need to stop a process like that because the server is under too much pressure. I'm sure it's possible but then again even if our biggest tables got all their stats updated at the same time. I would never have enough time to get the call and open ssms. Granted our biggest tables only have a few GBs and a fullscan stats update is done is seconds.

    That's why I'm asking who ever had to run that and under what circumstances?

  • Ninja's_RGR'us (4/29/2011)


    Tom.Thomson (4/29/2011)


    Ninja's_RGR'us (4/29/2011)


    Glad to learn that but why would you have to run that?

    Even if by some accident you unintentionnally started update stats with fullscan on a 2 TB table, you could still kill your spid to stop it.

    But if it's an asynchronous job it's not running in your spid - how to you find the spid for it?

    I'm curious, has anybody ever needed to do that?

    Not me, for sure.

    What's hard to wrap my mind around is the need to stop a process like that because the server is under too much pressure. I'm sure it's possible but then again even if our biggest tables got all their stats updated at the same time. I would never have enough time to get the call and open ssms. Granted our biggest tables only have a few GBs and a fullscan stats update is done is seconds.

    That's why I'm asking who ever had to run that and under what circumstances?

    Oh, I agree with you totally about that. That's what I meant to convey by that "for sure", I guess I got that bit of English usage wrong.

    Tom

  • I understood what you meant, I just felt I had to clarify even further... nothing wrong wiht ioure anglich dud! 😉

  • Ninja's_RGR'us (4/29/2011)


    Even if by some accident you unintentionnally started update stats with fullscan on a 2 TB table, you could still kill your spid to stop it.

    It's asynchronous so I would assume killing the SPID wouldn't affect the job. Especially because, at least theoretically, the query can be done before the asynchronous stats up date is done.

    I looked around online and the only thing I saw about using it is to make sure that when you are going to single user mode to make sure that the async job doesn't grab the only session.

    http://blogs.msdn.com/b/euanga/archive/2007/10/03/forcing-termination-of-user-sql-sessions-so-i-can-drop-database.aspx

  • cfradenburg (4/29/2011)


    Ninja's_RGR'us (4/29/2011)


    Even if by some accident you unintentionnally started update stats with fullscan on a 2 TB table, you could still kill your spid to stop it.

    It's asynchronous so I would assume killing the SPID wouldn't affect the job. Especially because, at least theoretically, the query can be done before the asynchronous stats up date is done.

    I looked around online and the only thing I saw about using it is to make sure that when you are going to single user mode to make sure that the async job doesn't grab the only session.

    http://blogs.msdn.com/b/euanga/archive/2007/10/03/forcing-termination-of-user-sql-sessions-so-i-can-drop-database.aspx

    Ya that would be a PITA.

    Maybe I missed it but I can't see a with async option on the create/update stats command. Does that mean that the setting is only at the db level and that if you have async ON and then you issue an update stats command, then it does like sp_startjob and does't wait for completion before completing the batch?

  • Lucky guess for me and a great question! Another interesting tidbit.

    A word of advice for everyone who is interested in these little morsels of SQL filler.

    Read the MCM reading list. It is full of stuff like this.

    Peter Trast
    Microsoft Certified ...(insert many literal strings here)
    Microsoft Design Architect with Alexander Open Systems

  • Thanks Steve,

    Learned something... not sure that I'll need to use it any time soon, but it's good to know.



    --Mark Tassin
    MCITP - SQL Server DBA
    Proud member of the Anti-RBAR alliance.
    For help with Performance click this link[/url]
    For tips on how to post your problems[/url]

Viewing 15 posts - 1 through 15 (of 20 total)

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