Đây là một T-SQL script hay giúp maintenance index, sử dụng DMV sys.dm_db_index_physical_stats giúp công việc bảo trì Index hiệu quả và nhanh chóng hơn SQL Server Maintenance Plans Wizard, vì tiện ích có sẵn của SQL Server chỉ có 2 tùy chọn là:
- Không làm gì cả
- Giải phân mảnh cho tất cả index cho 1 hay nhiều database, ta không thể tùy biến ví dụ như ưu tiên giải phân mảnh cho những index quan trọng.
- CommandLog Cleanup
- DatabaseBackup - USER_DATABASES – FULL
- DatabaseBackup - USER_DATABASES – DIFF
- DatabaseBackup - USER_DATABASES – LOG
- DatabaseBackup - SYSTEM_DATABASES – FULL
- DatabaseIntegrityCheck - USER_DATABASES
- DatabaseIntegrityCheck - SYSTEM_DATABASES
- IndexOptimize - USER_DATABASES
- Output File Cleanup
- sp_delete_backuphistory
- sp_purge_jobhistory
Tham khảo: http://ola.hallengren.com/
https://www.simple-talk.com/sql/database-administration/automate-and-improve-your-database-maintenance-using-ola-hallengrens-free-script/
0 comments:
Post a Comment