dbcc cleantable batch size explanationIs there a reliable way to determine when you should run DBCC CLEANTABLE to reclaim space?why SELECT is still using CPU & DiskIO?DBCC CHECKDB ran out of memoryDifference size DBCC Page and DBCC FileheaderHeavy I/O for Microsoft Transaction LogReclaim space from dropped column when there isn't enough space for index rebuildInteresting DBCC CHECKDB scenarioExtracted data WAY bigger than deficit left from deleted rowsWhat can cause DBCC CheckDB to take longer than usual?Reclaim space from dropped column in SQLServer2008R2

Paid for article while in US on F-1 visa?

Is it possible to do 50 km distance without any previous training?

What does "Puller Prush Person" mean?

Why are electrically insulating heatsinks so rare? Is it just cost?

Can I make popcorn with any corn?

Maximum likelihood parameters deviate from posterior distributions

Which country benefited the most from UN Security Council vetoes?

How does one intimidate enemies without having the capacity for violence?

What does it mean to describe someone as a butt steak?

Does an object always see its latest internal state irrespective of thread?

Do infinite dimensional systems make sense?

Cross compiling for RPi - error while loading shared libraries

What doth I be?

Add text to same line using sed

Horror movie about a virus at the prom; beginning and end are stylized as a cartoon

Codimension of non-flat locus

How old can references or sources in a thesis be?

Why is consensus so controversial in Britain?

What defenses are there against being summoned by the Gate spell?

How is it possible to have an ability score that is less than 3?

LWC SFDX source push error TypeError: LWC1009: decl.moveTo is not a function

What's that red-plus icon near a text?

infared filters v nd

Do I have a twin with permutated remainders?



dbcc cleantable batch size explanation


Is there a reliable way to determine when you should run DBCC CLEANTABLE to reclaim space?why SELECT is still using CPU & DiskIO?DBCC CHECKDB ran out of memoryDifference size DBCC Page and DBCC FileheaderHeavy I/O for Microsoft Transaction LogReclaim space from dropped column when there isn't enough space for index rebuildInteresting DBCC CHECKDB scenarioExtracted data WAY bigger than deficit left from deleted rowsWhat can cause DBCC CheckDB to take longer than usual?Reclaim space from dropped column in SQLServer2008R2






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








5















I have a very large table with 500 mil rows and a Text column that I will be dropping.
In my Dev environment, I have dropped the column and began the reclaim process, but im not sure what the batch size on the “DBCC CLEANTABLE (MyDb,'dbo.LargeTbl, 100000)” statement actually does.



I have tried setting it to 5, expecting it to check the first 5 rows and end. “DBCC CLEANTABLE (MyDb,'dbo.LargeTbl, 5)” and it took 28 hours.
So I restored the db, set it to 100,000 and it took 4 hours



Actual Question:
Does the batch size tell the dbcc cleantable how many rows to do at a time and continuously keep running 100K at a time till it goes thru all 500mil rows?
Or once I run the 100,000 do I have to run it again till I do all 500 mil rows?



On my second test, (running the 100K once) I was able to reclaim 30GB. Then I ran an index reorg on ALL indexes and reclaimed and additional 60GB..










share|improve this question






























    5















    I have a very large table with 500 mil rows and a Text column that I will be dropping.
    In my Dev environment, I have dropped the column and began the reclaim process, but im not sure what the batch size on the “DBCC CLEANTABLE (MyDb,'dbo.LargeTbl, 100000)” statement actually does.



    I have tried setting it to 5, expecting it to check the first 5 rows and end. “DBCC CLEANTABLE (MyDb,'dbo.LargeTbl, 5)” and it took 28 hours.
    So I restored the db, set it to 100,000 and it took 4 hours



    Actual Question:
    Does the batch size tell the dbcc cleantable how many rows to do at a time and continuously keep running 100K at a time till it goes thru all 500mil rows?
    Or once I run the 100,000 do I have to run it again till I do all 500 mil rows?



    On my second test, (running the 100K once) I was able to reclaim 30GB. Then I ran an index reorg on ALL indexes and reclaimed and additional 60GB..










    share|improve this question


























      5












      5








      5








      I have a very large table with 500 mil rows and a Text column that I will be dropping.
      In my Dev environment, I have dropped the column and began the reclaim process, but im not sure what the batch size on the “DBCC CLEANTABLE (MyDb,'dbo.LargeTbl, 100000)” statement actually does.



      I have tried setting it to 5, expecting it to check the first 5 rows and end. “DBCC CLEANTABLE (MyDb,'dbo.LargeTbl, 5)” and it took 28 hours.
      So I restored the db, set it to 100,000 and it took 4 hours



      Actual Question:
      Does the batch size tell the dbcc cleantable how many rows to do at a time and continuously keep running 100K at a time till it goes thru all 500mil rows?
      Or once I run the 100,000 do I have to run it again till I do all 500 mil rows?



      On my second test, (running the 100K once) I was able to reclaim 30GB. Then I ran an index reorg on ALL indexes and reclaimed and additional 60GB..










      share|improve this question
















      I have a very large table with 500 mil rows and a Text column that I will be dropping.
      In my Dev environment, I have dropped the column and began the reclaim process, but im not sure what the batch size on the “DBCC CLEANTABLE (MyDb,'dbo.LargeTbl, 100000)” statement actually does.



      I have tried setting it to 5, expecting it to check the first 5 rows and end. “DBCC CLEANTABLE (MyDb,'dbo.LargeTbl, 5)” and it took 28 hours.
      So I restored the db, set it to 100,000 and it took 4 hours



      Actual Question:
      Does the batch size tell the dbcc cleantable how many rows to do at a time and continuously keep running 100K at a time till it goes thru all 500mil rows?
      Or once I run the 100,000 do I have to run it again till I do all 500 mil rows?



      On my second test, (running the 100K once) I was able to reclaim 30GB. Then I ran an index reorg on ALL indexes and reclaimed and additional 60GB..







      sql-server sql-server-2016 dbcc






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 11 hours ago









      Paul White

      54.1k14287460




      54.1k14287460










      asked 11 hours ago









      TomaszTomasz

      806




      806




















          2 Answers
          2






          active

          oldest

          votes


















          7














          In addition to the great answer by armitage you probably do not need to use DBCC CLEANTABLE in your scenario.



          You state




          Then I ran an index reorg on ALL indexes and reclaimed and additional 60GB..




          The best practices in the Microsoft documents says:




          DBCC CLEANTABLE should not be executed as a routine maintenance task. Instead, use DBCC CLEANTABLE after you make significant changes to variable-length columns in a table or indexed view and you need to immediately reclaim the unused space. Alternatively, you can rebuild the indexes on the table or view; however, doing so is a more resource-intensive operation.




          It seems like time and space are your biggest goals. Generally rebuilding an index is quicker (but more resource intensive) than a reorg.



          As you are working on a Development server.



          Just rebuild your indexes and you will get the benefits of the index reorg and the DBCC CLEANTABLE at the same time, and probably much quicker.



          Note Rebuild and Reorganize are not the same thing:



          • Reorganize and Rebuild Indexes (Microsoft)

          • Rebuild or Reorganize: SQL Server Index Maintenance (Brent Ozar)

          • SQLskills SQL101: REBUILD vs. REORGANIZE(Paul Randal)





          share|improve this answer

























          • i thought the same thing and ran the test in reverse. 1) dropped the column 2) defrag all indexes (only reclaimed 30GB) 3) ran cleantable and got 60gb... looks like i need both, this is a one time thing

            – Tomasz
            10 hours ago












          • @Tomasz I edited my answer, not sure what you mean by 'defrag all indexes' but Reorg (what you said in your question) & Rebuild (what I said in this answer) are not the same thing.

            – James Jenkins
            10 hours ago







          • 1





            ah, sorry. i reorganized them each time. i will run one more test where i will drop the column and rebuild the index and share the results. thank you.

            – Tomasz
            9 hours ago


















          3














          According to the Microsoft documentation the Batch Size tells the DBCC CleanTable the number of rows to process per transaction. This relates to the number of rows that the DBCC CleanTable processes internally as the DBCC CleanTable process runs.



          By taking the example in the documentation and modifying to add a million rows and then running the sample script multiple times with varying values for batch size ( see below) it appears that specifying a small batch size increase the execution time as DBCC CleanTable is only operating on the number of rows specified in the batch size.



          • No Batch size specified

          • A batch size of 5

          • A batch size of 100,00





          share|improve this answer























          • So just to confirm, the process will go thru the entire 500Mil rows, just "exclusively locking" 100K at a time and also allow for backup logs to occur.

            – Tomasz
            10 hours ago











          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%2f234041%2fdbcc-cleantable-batch-size-explanation%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          7














          In addition to the great answer by armitage you probably do not need to use DBCC CLEANTABLE in your scenario.



          You state




          Then I ran an index reorg on ALL indexes and reclaimed and additional 60GB..




          The best practices in the Microsoft documents says:




          DBCC CLEANTABLE should not be executed as a routine maintenance task. Instead, use DBCC CLEANTABLE after you make significant changes to variable-length columns in a table or indexed view and you need to immediately reclaim the unused space. Alternatively, you can rebuild the indexes on the table or view; however, doing so is a more resource-intensive operation.




          It seems like time and space are your biggest goals. Generally rebuilding an index is quicker (but more resource intensive) than a reorg.



          As you are working on a Development server.



          Just rebuild your indexes and you will get the benefits of the index reorg and the DBCC CLEANTABLE at the same time, and probably much quicker.



          Note Rebuild and Reorganize are not the same thing:



          • Reorganize and Rebuild Indexes (Microsoft)

          • Rebuild or Reorganize: SQL Server Index Maintenance (Brent Ozar)

          • SQLskills SQL101: REBUILD vs. REORGANIZE(Paul Randal)





          share|improve this answer

























          • i thought the same thing and ran the test in reverse. 1) dropped the column 2) defrag all indexes (only reclaimed 30GB) 3) ran cleantable and got 60gb... looks like i need both, this is a one time thing

            – Tomasz
            10 hours ago












          • @Tomasz I edited my answer, not sure what you mean by 'defrag all indexes' but Reorg (what you said in your question) & Rebuild (what I said in this answer) are not the same thing.

            – James Jenkins
            10 hours ago







          • 1





            ah, sorry. i reorganized them each time. i will run one more test where i will drop the column and rebuild the index and share the results. thank you.

            – Tomasz
            9 hours ago















          7














          In addition to the great answer by armitage you probably do not need to use DBCC CLEANTABLE in your scenario.



          You state




          Then I ran an index reorg on ALL indexes and reclaimed and additional 60GB..




          The best practices in the Microsoft documents says:




          DBCC CLEANTABLE should not be executed as a routine maintenance task. Instead, use DBCC CLEANTABLE after you make significant changes to variable-length columns in a table or indexed view and you need to immediately reclaim the unused space. Alternatively, you can rebuild the indexes on the table or view; however, doing so is a more resource-intensive operation.




          It seems like time and space are your biggest goals. Generally rebuilding an index is quicker (but more resource intensive) than a reorg.



          As you are working on a Development server.



          Just rebuild your indexes and you will get the benefits of the index reorg and the DBCC CLEANTABLE at the same time, and probably much quicker.



          Note Rebuild and Reorganize are not the same thing:



          • Reorganize and Rebuild Indexes (Microsoft)

          • Rebuild or Reorganize: SQL Server Index Maintenance (Brent Ozar)

          • SQLskills SQL101: REBUILD vs. REORGANIZE(Paul Randal)





          share|improve this answer

























          • i thought the same thing and ran the test in reverse. 1) dropped the column 2) defrag all indexes (only reclaimed 30GB) 3) ran cleantable and got 60gb... looks like i need both, this is a one time thing

            – Tomasz
            10 hours ago












          • @Tomasz I edited my answer, not sure what you mean by 'defrag all indexes' but Reorg (what you said in your question) & Rebuild (what I said in this answer) are not the same thing.

            – James Jenkins
            10 hours ago







          • 1





            ah, sorry. i reorganized them each time. i will run one more test where i will drop the column and rebuild the index and share the results. thank you.

            – Tomasz
            9 hours ago













          7












          7








          7







          In addition to the great answer by armitage you probably do not need to use DBCC CLEANTABLE in your scenario.



          You state




          Then I ran an index reorg on ALL indexes and reclaimed and additional 60GB..




          The best practices in the Microsoft documents says:




          DBCC CLEANTABLE should not be executed as a routine maintenance task. Instead, use DBCC CLEANTABLE after you make significant changes to variable-length columns in a table or indexed view and you need to immediately reclaim the unused space. Alternatively, you can rebuild the indexes on the table or view; however, doing so is a more resource-intensive operation.




          It seems like time and space are your biggest goals. Generally rebuilding an index is quicker (but more resource intensive) than a reorg.



          As you are working on a Development server.



          Just rebuild your indexes and you will get the benefits of the index reorg and the DBCC CLEANTABLE at the same time, and probably much quicker.



          Note Rebuild and Reorganize are not the same thing:



          • Reorganize and Rebuild Indexes (Microsoft)

          • Rebuild or Reorganize: SQL Server Index Maintenance (Brent Ozar)

          • SQLskills SQL101: REBUILD vs. REORGANIZE(Paul Randal)





          share|improve this answer















          In addition to the great answer by armitage you probably do not need to use DBCC CLEANTABLE in your scenario.



          You state




          Then I ran an index reorg on ALL indexes and reclaimed and additional 60GB..




          The best practices in the Microsoft documents says:




          DBCC CLEANTABLE should not be executed as a routine maintenance task. Instead, use DBCC CLEANTABLE after you make significant changes to variable-length columns in a table or indexed view and you need to immediately reclaim the unused space. Alternatively, you can rebuild the indexes on the table or view; however, doing so is a more resource-intensive operation.




          It seems like time and space are your biggest goals. Generally rebuilding an index is quicker (but more resource intensive) than a reorg.



          As you are working on a Development server.



          Just rebuild your indexes and you will get the benefits of the index reorg and the DBCC CLEANTABLE at the same time, and probably much quicker.



          Note Rebuild and Reorganize are not the same thing:



          • Reorganize and Rebuild Indexes (Microsoft)

          • Rebuild or Reorganize: SQL Server Index Maintenance (Brent Ozar)

          • SQLskills SQL101: REBUILD vs. REORGANIZE(Paul Randal)






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 9 hours ago

























          answered 10 hours ago









          James JenkinsJames Jenkins

          2,04022045




          2,04022045












          • i thought the same thing and ran the test in reverse. 1) dropped the column 2) defrag all indexes (only reclaimed 30GB) 3) ran cleantable and got 60gb... looks like i need both, this is a one time thing

            – Tomasz
            10 hours ago












          • @Tomasz I edited my answer, not sure what you mean by 'defrag all indexes' but Reorg (what you said in your question) & Rebuild (what I said in this answer) are not the same thing.

            – James Jenkins
            10 hours ago







          • 1





            ah, sorry. i reorganized them each time. i will run one more test where i will drop the column and rebuild the index and share the results. thank you.

            – Tomasz
            9 hours ago

















          • i thought the same thing and ran the test in reverse. 1) dropped the column 2) defrag all indexes (only reclaimed 30GB) 3) ran cleantable and got 60gb... looks like i need both, this is a one time thing

            – Tomasz
            10 hours ago












          • @Tomasz I edited my answer, not sure what you mean by 'defrag all indexes' but Reorg (what you said in your question) & Rebuild (what I said in this answer) are not the same thing.

            – James Jenkins
            10 hours ago







          • 1





            ah, sorry. i reorganized them each time. i will run one more test where i will drop the column and rebuild the index and share the results. thank you.

            – Tomasz
            9 hours ago
















          i thought the same thing and ran the test in reverse. 1) dropped the column 2) defrag all indexes (only reclaimed 30GB) 3) ran cleantable and got 60gb... looks like i need both, this is a one time thing

          – Tomasz
          10 hours ago






          i thought the same thing and ran the test in reverse. 1) dropped the column 2) defrag all indexes (only reclaimed 30GB) 3) ran cleantable and got 60gb... looks like i need both, this is a one time thing

          – Tomasz
          10 hours ago














          @Tomasz I edited my answer, not sure what you mean by 'defrag all indexes' but Reorg (what you said in your question) & Rebuild (what I said in this answer) are not the same thing.

          – James Jenkins
          10 hours ago






          @Tomasz I edited my answer, not sure what you mean by 'defrag all indexes' but Reorg (what you said in your question) & Rebuild (what I said in this answer) are not the same thing.

          – James Jenkins
          10 hours ago





          1




          1





          ah, sorry. i reorganized them each time. i will run one more test where i will drop the column and rebuild the index and share the results. thank you.

          – Tomasz
          9 hours ago





          ah, sorry. i reorganized them each time. i will run one more test where i will drop the column and rebuild the index and share the results. thank you.

          – Tomasz
          9 hours ago













          3














          According to the Microsoft documentation the Batch Size tells the DBCC CleanTable the number of rows to process per transaction. This relates to the number of rows that the DBCC CleanTable processes internally as the DBCC CleanTable process runs.



          By taking the example in the documentation and modifying to add a million rows and then running the sample script multiple times with varying values for batch size ( see below) it appears that specifying a small batch size increase the execution time as DBCC CleanTable is only operating on the number of rows specified in the batch size.



          • No Batch size specified

          • A batch size of 5

          • A batch size of 100,00





          share|improve this answer























          • So just to confirm, the process will go thru the entire 500Mil rows, just "exclusively locking" 100K at a time and also allow for backup logs to occur.

            – Tomasz
            10 hours ago















          3














          According to the Microsoft documentation the Batch Size tells the DBCC CleanTable the number of rows to process per transaction. This relates to the number of rows that the DBCC CleanTable processes internally as the DBCC CleanTable process runs.



          By taking the example in the documentation and modifying to add a million rows and then running the sample script multiple times with varying values for batch size ( see below) it appears that specifying a small batch size increase the execution time as DBCC CleanTable is only operating on the number of rows specified in the batch size.



          • No Batch size specified

          • A batch size of 5

          • A batch size of 100,00





          share|improve this answer























          • So just to confirm, the process will go thru the entire 500Mil rows, just "exclusively locking" 100K at a time and also allow for backup logs to occur.

            – Tomasz
            10 hours ago













          3












          3








          3







          According to the Microsoft documentation the Batch Size tells the DBCC CleanTable the number of rows to process per transaction. This relates to the number of rows that the DBCC CleanTable processes internally as the DBCC CleanTable process runs.



          By taking the example in the documentation and modifying to add a million rows and then running the sample script multiple times with varying values for batch size ( see below) it appears that specifying a small batch size increase the execution time as DBCC CleanTable is only operating on the number of rows specified in the batch size.



          • No Batch size specified

          • A batch size of 5

          • A batch size of 100,00





          share|improve this answer













          According to the Microsoft documentation the Batch Size tells the DBCC CleanTable the number of rows to process per transaction. This relates to the number of rows that the DBCC CleanTable processes internally as the DBCC CleanTable process runs.



          By taking the example in the documentation and modifying to add a million rows and then running the sample script multiple times with varying values for batch size ( see below) it appears that specifying a small batch size increase the execution time as DBCC CleanTable is only operating on the number of rows specified in the batch size.



          • No Batch size specified

          • A batch size of 5

          • A batch size of 100,00






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 11 hours ago









          armitagearmitage

          838512




          838512












          • So just to confirm, the process will go thru the entire 500Mil rows, just "exclusively locking" 100K at a time and also allow for backup logs to occur.

            – Tomasz
            10 hours ago

















          • So just to confirm, the process will go thru the entire 500Mil rows, just "exclusively locking" 100K at a time and also allow for backup logs to occur.

            – Tomasz
            10 hours ago
















          So just to confirm, the process will go thru the entire 500Mil rows, just "exclusively locking" 100K at a time and also allow for backup logs to occur.

          – Tomasz
          10 hours ago





          So just to confirm, the process will go thru the entire 500Mil rows, just "exclusively locking" 100K at a time and also allow for backup logs to occur.

          – Tomasz
          10 hours ago

















          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%2f234041%2fdbcc-cleantable-batch-size-explanation%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

          Magento 2 duplicate PHPSESSID cookie when using session_start() in custom php scriptMagento 2: User cant logged in into to account page, no error showing!Magento duplicate on subdomainGrabbing storeview from cookie (after using language selector)How do I run php custom script on magento2Magento 2: Include PHP script in headerSession lock after using Cm_RedisSessionscript php to update stockMagento set cookie popupMagento 2 session id cookie - where to find it?How to import Configurable product from csv with custom attributes using php scriptMagento 2 run custom PHP script

          Can not update quote_id field of “quote_item” table magento 2Magento 2.1 - We can't remove the item. (Shopping Cart doesnt allow us to remove items before becomes empty)Add value for custom quote item attribute using REST apiREST API endpoint v1/carts/cartId/items always returns error messageCorrect way to save entries to databaseHow to remove all associated quote objects of a customer completelyMagento 2 - Save value from custom input field to quote_itemGet quote_item data using quote id and product id filter in Magento 2How to set additional data to quote_item table from controller in Magento 2?What is the purpose of additional_data column in quote_item table in magento2Set Custom Price to Quote item magento2 from controller

          How to solve knockout JS error in Magento 2 Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?(Magento2) knockout.js:3012 Uncaught ReferenceError: Unable to process bindingUnable to process binding Knockout.js magento 2Cannot read property `scopeLabel` of undefined on Product Detail PageCan't get Customer Data on frontend in Magento 2Magento2 Order Summary - unable to process bindingKO templates are not loading in Magento 2.1 applicationgetting knockout js error magento 2Product grid not load -— Unable to process binding Knockout.js magento 2Product form not loaded in magento2Uncaught ReferenceError: Unable to process binding “if: function()return (isShowLegend()) ” magento 2