SQL queries to find tempdb bloating












1















I am trying to find out the queries which would have run and caused bloat to TempDB.



I am able to pull data like TempDB bloating on one particular day where it almost ate upto 300 GB of space, was somewhere in middle of last week.



As per post How to find the SQL statements that caused tempdb growth?, i can find below data but not sure how to interpret this as i can find host and login, but not the actual queries.



status  CPU TIME (in milisec)   Total Scheduled TIME (in milisec)   Elapsed TIME (in milisec)   Memory USAGE (in KB)    SPACE Allocated FOR USER Objects (in KB)    SPACE Deallocated FOR USER Objects (in KB)  SPACE Allocated FOR Internal Objects (in KB)    SPACE Deallocated FOR Internal Objects (in KB)  SESSION Type    ROW COUNT
sleeping 4428523 4618020 5418422 24 0 648 38349248 38351104 user session 1
sleeping 4411334 4578428 5389351 24 0 672 41238720 41240448 user session 1
sleeping 4601627 4820643 5631623 24 0 720 40119104 40121280 user session 1
sleeping 12887505 13667397 15209924 24 0 3528 46007808 46013184 user session 1
sleeping 4589595 4792873 5835456 24 0 528 39140800 39142528 user session 1
sleeping 6416738 6767615 7836356 24 0 1088 40406400 40408768 user session 1
sleeping 8626603 9072173 10416679 24 0 1488 43888640 43891584 user session 1
sleeping 4346345 4554241 5389904 24 0 976 39358208 39360128 user session 1
sleeping 11817344 12427608 13494857 24 0 3208 46888512 46894208 user session 1
sleeping 5182063 5435636 6242939 24 0 680 37975040 37977024 user session 1


Is there a way i can really find queries which caused almost 300 GB bloat last week.



Yes, am aware of 3rd party tools which would have save the info. But we do not have one on this. How can i find one if possible?










share|improve this question



























    1















    I am trying to find out the queries which would have run and caused bloat to TempDB.



    I am able to pull data like TempDB bloating on one particular day where it almost ate upto 300 GB of space, was somewhere in middle of last week.



    As per post How to find the SQL statements that caused tempdb growth?, i can find below data but not sure how to interpret this as i can find host and login, but not the actual queries.



    status  CPU TIME (in milisec)   Total Scheduled TIME (in milisec)   Elapsed TIME (in milisec)   Memory USAGE (in KB)    SPACE Allocated FOR USER Objects (in KB)    SPACE Deallocated FOR USER Objects (in KB)  SPACE Allocated FOR Internal Objects (in KB)    SPACE Deallocated FOR Internal Objects (in KB)  SESSION Type    ROW COUNT
    sleeping 4428523 4618020 5418422 24 0 648 38349248 38351104 user session 1
    sleeping 4411334 4578428 5389351 24 0 672 41238720 41240448 user session 1
    sleeping 4601627 4820643 5631623 24 0 720 40119104 40121280 user session 1
    sleeping 12887505 13667397 15209924 24 0 3528 46007808 46013184 user session 1
    sleeping 4589595 4792873 5835456 24 0 528 39140800 39142528 user session 1
    sleeping 6416738 6767615 7836356 24 0 1088 40406400 40408768 user session 1
    sleeping 8626603 9072173 10416679 24 0 1488 43888640 43891584 user session 1
    sleeping 4346345 4554241 5389904 24 0 976 39358208 39360128 user session 1
    sleeping 11817344 12427608 13494857 24 0 3208 46888512 46894208 user session 1
    sleeping 5182063 5435636 6242939 24 0 680 37975040 37977024 user session 1


    Is there a way i can really find queries which caused almost 300 GB bloat last week.



    Yes, am aware of 3rd party tools which would have save the info. But we do not have one on this. How can i find one if possible?










    share|improve this question

























      1












      1








      1








      I am trying to find out the queries which would have run and caused bloat to TempDB.



      I am able to pull data like TempDB bloating on one particular day where it almost ate upto 300 GB of space, was somewhere in middle of last week.



      As per post How to find the SQL statements that caused tempdb growth?, i can find below data but not sure how to interpret this as i can find host and login, but not the actual queries.



      status  CPU TIME (in milisec)   Total Scheduled TIME (in milisec)   Elapsed TIME (in milisec)   Memory USAGE (in KB)    SPACE Allocated FOR USER Objects (in KB)    SPACE Deallocated FOR USER Objects (in KB)  SPACE Allocated FOR Internal Objects (in KB)    SPACE Deallocated FOR Internal Objects (in KB)  SESSION Type    ROW COUNT
      sleeping 4428523 4618020 5418422 24 0 648 38349248 38351104 user session 1
      sleeping 4411334 4578428 5389351 24 0 672 41238720 41240448 user session 1
      sleeping 4601627 4820643 5631623 24 0 720 40119104 40121280 user session 1
      sleeping 12887505 13667397 15209924 24 0 3528 46007808 46013184 user session 1
      sleeping 4589595 4792873 5835456 24 0 528 39140800 39142528 user session 1
      sleeping 6416738 6767615 7836356 24 0 1088 40406400 40408768 user session 1
      sleeping 8626603 9072173 10416679 24 0 1488 43888640 43891584 user session 1
      sleeping 4346345 4554241 5389904 24 0 976 39358208 39360128 user session 1
      sleeping 11817344 12427608 13494857 24 0 3208 46888512 46894208 user session 1
      sleeping 5182063 5435636 6242939 24 0 680 37975040 37977024 user session 1


      Is there a way i can really find queries which caused almost 300 GB bloat last week.



      Yes, am aware of 3rd party tools which would have save the info. But we do not have one on this. How can i find one if possible?










      share|improve this question














      I am trying to find out the queries which would have run and caused bloat to TempDB.



      I am able to pull data like TempDB bloating on one particular day where it almost ate upto 300 GB of space, was somewhere in middle of last week.



      As per post How to find the SQL statements that caused tempdb growth?, i can find below data but not sure how to interpret this as i can find host and login, but not the actual queries.



      status  CPU TIME (in milisec)   Total Scheduled TIME (in milisec)   Elapsed TIME (in milisec)   Memory USAGE (in KB)    SPACE Allocated FOR USER Objects (in KB)    SPACE Deallocated FOR USER Objects (in KB)  SPACE Allocated FOR Internal Objects (in KB)    SPACE Deallocated FOR Internal Objects (in KB)  SESSION Type    ROW COUNT
      sleeping 4428523 4618020 5418422 24 0 648 38349248 38351104 user session 1
      sleeping 4411334 4578428 5389351 24 0 672 41238720 41240448 user session 1
      sleeping 4601627 4820643 5631623 24 0 720 40119104 40121280 user session 1
      sleeping 12887505 13667397 15209924 24 0 3528 46007808 46013184 user session 1
      sleeping 4589595 4792873 5835456 24 0 528 39140800 39142528 user session 1
      sleeping 6416738 6767615 7836356 24 0 1088 40406400 40408768 user session 1
      sleeping 8626603 9072173 10416679 24 0 1488 43888640 43891584 user session 1
      sleeping 4346345 4554241 5389904 24 0 976 39358208 39360128 user session 1
      sleeping 11817344 12427608 13494857 24 0 3208 46888512 46894208 user session 1
      sleeping 5182063 5435636 6242939 24 0 680 37975040 37977024 user session 1


      Is there a way i can really find queries which caused almost 300 GB bloat last week.



      Yes, am aware of 3rd party tools which would have save the info. But we do not have one on this. How can i find one if possible?







      sql-server sql-server-2012 tempdb






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 26 '18 at 18:20









      BeginnerDBABeginnerDBA

      5151417




      5151417






















          1 Answer
          1






          active

          oldest

          votes


















          1














          By default, SQL Server does not track and record queries that causing growth of TempDB. Moreover, even running SQL Profiler session would not help in this case.



          However, extended events is an option. Brent Ozar has a blog post with an example:



          Tracking tempdb growth using Extended Events



          XE sessions are more lightweight than SQL Profiler traces. Moreover, your servers, perhaps, already have two or three running now, by default.



          XE sessions can be setup to target a ringbuffer, so they can be completely in memory and catch queries that exceed some threshold, for instance 20 GB or more. In this case, risk that they will cause any issues are minimal.






          share|improve this answer

























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "182"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f202325%2fsql-queries-to-find-tempdb-bloating%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            By default, SQL Server does not track and record queries that causing growth of TempDB. Moreover, even running SQL Profiler session would not help in this case.



            However, extended events is an option. Brent Ozar has a blog post with an example:



            Tracking tempdb growth using Extended Events



            XE sessions are more lightweight than SQL Profiler traces. Moreover, your servers, perhaps, already have two or three running now, by default.



            XE sessions can be setup to target a ringbuffer, so they can be completely in memory and catch queries that exceed some threshold, for instance 20 GB or more. In this case, risk that they will cause any issues are minimal.






            share|improve this answer






























              1














              By default, SQL Server does not track and record queries that causing growth of TempDB. Moreover, even running SQL Profiler session would not help in this case.



              However, extended events is an option. Brent Ozar has a blog post with an example:



              Tracking tempdb growth using Extended Events



              XE sessions are more lightweight than SQL Profiler traces. Moreover, your servers, perhaps, already have two or three running now, by default.



              XE sessions can be setup to target a ringbuffer, so they can be completely in memory and catch queries that exceed some threshold, for instance 20 GB or more. In this case, risk that they will cause any issues are minimal.






              share|improve this answer




























                1












                1








                1







                By default, SQL Server does not track and record queries that causing growth of TempDB. Moreover, even running SQL Profiler session would not help in this case.



                However, extended events is an option. Brent Ozar has a blog post with an example:



                Tracking tempdb growth using Extended Events



                XE sessions are more lightweight than SQL Profiler traces. Moreover, your servers, perhaps, already have two or three running now, by default.



                XE sessions can be setup to target a ringbuffer, so they can be completely in memory and catch queries that exceed some threshold, for instance 20 GB or more. In this case, risk that they will cause any issues are minimal.






                share|improve this answer















                By default, SQL Server does not track and record queries that causing growth of TempDB. Moreover, even running SQL Profiler session would not help in this case.



                However, extended events is an option. Brent Ozar has a blog post with an example:



                Tracking tempdb growth using Extended Events



                XE sessions are more lightweight than SQL Profiler traces. Moreover, your servers, perhaps, already have two or three running now, by default.



                XE sessions can be setup to target a ringbuffer, so they can be completely in memory and catch queries that exceed some threshold, for instance 20 GB or more. In this case, risk that they will cause any issues are minimal.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited 15 mins ago









                Paul White

                51.5k14278450




                51.5k14278450










                answered Mar 26 '18 at 19:08









                Alexandr VolokAlexandr Volok

                27115




                27115






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Database Administrators Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f202325%2fsql-queries-to-find-tempdb-bloating%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    ف. موراي أبراهام

                    صرب

                    كأس إنترتوتو