Need to execute database maintenance in multiple threading (session)

  • Hello Experts, 

    I have a SQL instance where we have couple of large databases eg. DB1 - 1.2 TB , DB2 - 1.5 TB.
    I have created maintenance plan to rebuild the indexes and update the statistics in sequential order. but it took 30+ Hrs to get completed. 
    As an experiment - I created manual rebuild script of all the indexes (Fragmentation >30) and divide into 3 part (approx equal size of all 3 parts according to index's size) and did same for update statistics (divide into 3 equal size according to table size).
    Then I have executed index script into 3 query window and after completion of this start update statistics in same manner (in 3 query window).
    This exercise took approx 16 Hrs to get completed and save my 14-15 hours. Now I want to automate this process. Can someone have an idea to automate it optimally by PowerShell etc.
    I don't want to create multiple (More than 2) SQL Jobs for this.

  • Look at Ola Hallengren's maintenance scripts.:
    https://ola.hallengren.com/sql-server-index-and-statistics-maintenance.html

  • When you rebuild an index it updates statistics as well.

  • Ols Hallengren's script doesn't provide multi-threading solution.

Viewing 4 posts - 1 through 3 (of 3 total)

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