Sql-server – Index rebuilding on mirrored database sql server 2008

database-mirroringsql serversql-server-2005sql-server-2008

I have a mirrored database in full safety mode on sql server 2008 R2 Standard Edition. I want to create a maintenance plan to rebuild and reorganize the indexes on a weekly basis. Maintenance plans are set to take full backups 3 times a day and transaction log backups every 30 minutes. The database is very active and gets lot of traffic. I tried rebuilding the indexes manually during non peak hours and that caused the log file to grow heavily on the principle as well as on the mirror.

Are there any specific steps to be followed for rebuilding indexes in a mirroring environment?
I searched online but could not find any difference in the way indexes are rebuilt in mirroring and without mirroring.

Also can I just use DBCC SHRINKFILE on the principle to free the unused space in the log file without stopping the mirroring?

Best Answer

I would strongly discourage you from regularly shrinking the log in a mirrored situation. One day your log will grow on the primary and not have disk space to grow on mirror, primary will not be able to ship log and will be pin the log in place until it grows ad-nauseam and you'll be cursing the job that shrinked your log as you won't be able to resume the mirroring without some complicated hockey-pockey.

If the log grows, it means it needs the extra space. Eventually it will stabilize at the right size and stop growing. That size, whatever will be, is the the operational size required for your log. If anything, you should grow your log right now so it stops growing automatically.

As for the index maintenance, do you have evidence that they need rebuilding at the frequency you're proposing? There is no way to avoid reduce the log space required during index rebuild operations if the database is mirrored.

Related Topic