SQL SERVER Management Studio – Rebuild All Indexes on Table

SSMS can open a Rebuild All dialog for table indexes. An e-commerce customer discovered this shortcut during my health check.

Several intact gears sit in a fitted case beside separate maintenance and inspection tools.

  1. Expand the database, Tables and the selected table in Object Explorer.
  2. Right-click its Indexes folder and choose Rebuild All where available.
  3. Review the listed indexes and options, then use Script to inspect the generated commands.
  4. Execute only after assessing the workload, maintenance window and available resources.
Original Indexes folder context menu showing Rebuild All.
Original Indexes folder context menu showing Rebuild All.
Original Rebuild All dialog; inspect its options and generated script before execution.
Original Rebuild All dialog; inspect its options and generated script before execution.

Opening the dialog does not execute the rebuild. Rebuilding consumes resources and can hold locks. Online availability depends on operation and edition. Fragmentation alone does not establish a workload benefit.

My historical seven-index preference was a review heuristic. It was not a SQL Server limit. Assess access paths, constraints, reads and write costs for each index. Measure before and after any justified maintenance.

Related reading

A maintenance dialog is not a measured tuning result, it is an interface for an operation that needs justification.

Published by Pinal Dave on SQLAuthority. More of my work at pinaldave.com.


Discover more from SQL Authority with Pinal Dave

Subscribe to get the latest posts sent to your email.

SQL Index, SQL Scripts, SQL Server, SQL Server Management Studio
Previous Post
Count NULLs in a Column in SQL Server: Five Ways Compared
Next Post
Msg 17177 in the SQL Server Error Log: What It Means

Related Posts

13 Comments. Leave new

  • Mohammed Benabdallah
    March 7, 2020 1:31 am

    Quick and easy tip, thanks for sharing

    Reply
  • Christopher D Wolff
    March 7, 2020 8:20 pm

    Be very careful with this if you are in an AG on the cloud. This may cause the secondary to get behind if your indexes are over 1 million pages. The main issue being the through put from the disk on the cloud providers

    Reply
  • Malcolm K Crowe
    March 8, 2020 12:35 am

    It’s a disgrace. You wouldn’t need it if the engine kept things consistent. If the indexes are wrong, how do you know whether the tables have been hacked?

    Reply
  • Kind of a pity you would have to resort to this at all, you would expect the indexing component to be able to optimise this for you.

    Reply
  • Anthony Griggs
    March 8, 2020 7:43 am

    I’m sure this probably sounds like a silly question to you but why would you want to rebuild the indexes? Obviously they already exist so what is the advantage to rebuild them again?

    Reply
    • If there are lots of insert/update/delete the index gets fragmentation and it needs to be rebuild to optimize the read.

      Reply
  • I have a situation, when i do rebuild on specific table is taking 11 minutes, but when i do rebuild on all tables is taking 3 minute. Why the first once is taking more than second one. Here i done rebuild offline . For the both cases i restore the database every time.

    Reply
  • What if a table does not rebuild its index, even though I’ve tried over and over??

    Reply
  • Carlos Ignacio Aguero
    September 20, 2023 9:31 pm

    After to restore databases, I have to rebuild index o not?

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.