• francesco.mantovani - Sunday, July 22, 2018 9:49 PM

    Hello @jeff, I was thinking this was a good idea for monitoring SQL Server on real time but maybe I'm wrong.
    Do you think my PowerShell script might be to heavy because it keeps running every second in an infinite loop? 
    Thank you

    First and again, just to be sure because it can be a sensitive subject.... in no way am I slamming you for the code.

    To answer your question, since it does run once a second, it does seem a bit heavy handed.  Of course, that can be easily changed.  Also, running once per second may be totally necessary when trying to troubleshoot a problem or when trying to establish some sort of pattern.

    I'm just not sure why so many people resort to PoSh for such things when it's actually simpler to do such a thing from T-SQL.  Also and in my case, having such an output go to the screen would be a bit overwhelming to review simply because of the number of databases present on my server.  It would be much better if it were logged to a semi-permanent scratch table with a sample date/time and contain the code in a DBA utility stored procedure where you could tell it not only what the sample rate should be but also how long it should sample with a decent set of defaults.  And, if necessary, the stored procedure could easily be scheduled as a one -time or regularly scheduled job to assist with late night troubleshooting.

    Yes, most of that can certainly be done in PoSh but why?

    To make a play on words similar to what I'm frequently told, "Just because you can do something in T-SQL, doesn't mean you SHOULDN'T". 😀

    --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)