WHAT'S NEW?
Loading...

Database index analysis and rebuild

Index


  • Intro
  • Analysis
  • Rebuild
  • References

Intro

This post is one of those quick ones which I hope you find at least useful. I just want to share with you a few TSQL scripts to help you analyze your SQL database indexes in order to rebuild them, just in case their fragmentation levels go out of the scale.


Analisis

The following script will give you a good understanding of how are your index fragmentation levels. Remember to replace the name of the database ('DATABASENAME') and tables ('Job'):


Rebuild

This scripts will rebuild the statistics for the indexes for every table in your database.

And finally we just need to rebuild the indexes. After running the script you can re-run the previous one to see the effects

References

https://msdn.microsoft.com/en-us/library/ms189858.aspx?f=255&MSPPError=-2147217396

0 comments:

Post a Comment