Estimate impact needed for rebuilding all indexes?

bitshift 71 Reputation points
2020-11-20T14:09:32.41+00:00

Have a 3rd party system that has a job that rebuilds all indexes nightly. We get periodic alerts when this happens that the TLog isnt big enough or a backup fails because the TLog is full. I know that rebuilding an index, and especially rebuilding ALL indexes for a large Db with several large tables, some of the indexes alone are over 1GB. How can I get a rough idea of the sizing needed for the Transaction Log(s) for the impact that the index rebuild will need? What about TempDb?
I realize there are many factors but where to start? One thing I consider is the total size of all the indexes. How can I use that number in estimating what the Tlog size should be to accommodate an index rebuild job?

SQL Server | Other
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. tibor_karaszi@hotmail.com 4,316 Reputation points
    2020-11-20T15:18:27.64+00:00

    Summarize the size of all indexes (including the clustered indexes for the tables that has clustered indexes). This will give you a rough idea about the space usage requirements for logging the operations. And work with that 3:rd party so they don't blindly rebuild all indexes! :-)

    1 person found this answer helpful.
    0 comments No comments

  2. Shashank Singh 6,251 Reputation points
    2020-11-20T15:08:48.457+00:00

    I know that rebuilding an index, and especially rebuilding ALL indexes for a large Db with several large tables,

    I understand that you know the disadvantages of rebuilding all indexes but I would reiterate that you are doing wrong. You MUST only rebuild indexes which are

    1. Fragmented > 30 %
    2. Having page_count > 2000

    Small indexes must be ignored.

    • How can I get a rough idea of the sizing needed for the Transaction Log(s) for the impact that the index rebuild will need?

    Did you got chance to read transaction-log-disk-space-for-index-operations and disk-space-requirements-for-index-ddl-operations I guess it has details about what you are asking. If you really want to do hard math see index-disk-space-Calculation-example. The last article has basically calculation/example to show how to get rough idea about disk space requirement for index.

    PS: There is no specific article but if you know your disk size of index and use sort_in_tempdb option

    0 comments No comments

  3. CathyJi-MSFT 22,396 Reputation points Microsoft External Staff
    2020-11-23T08:42:23.393+00:00

    Hi @bitshift ,

    Rebuilding an index needs enough space to create the new index. A simplified rule of thumb seems to be that you need about 120% of the space used by the original index. This may be in the database or in tempdb, depending on whether SORT_IN_TEMPDB is ON or OFF. If possible, have SORT_IN_TEMPDB = ON this will reduce some of the logging that is done.

    Refer to TRANSACTION LOG CONSEQUENCES ON REBUILDING SQL SERVER INDEXES to get detail information.

    Best regards,
    Cathy


    If the response is helpful, please click "Accept Answer" and upvote it.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.