1.数据库收缩会导致大量的索引碎片,这严重影响查询效率
2.任何时候禁用自动收缩
3.在必要的收缩之后,要处理因此而导致的索引碎片问题
收缩大数据库的建议:
- Create a new filegroup
- Move all affected tables and indexes into the new filegroup using
the CREATE INDEX … WITH (DROP_EXISTING = ON) ON syntax, to move
the tables and remove fragmentation from them at the same time
- Drop the old filegroup that you were going to shrink anyway (or
shrink it way down if its the primary filegroup)
收缩大数据库的建议:
https://www.sqlskills.com/blogs/paul/why-you-should-not-shrink-your-data-files/
索引碎片整理【建议使用reorganize而不是rebuild】:
https://docs.microsoft.com/en-us/sql/relational-databases/indexes/reorganize-and-rebuild-indexes?view=sql-server-2017
数据库收缩:
https://docs.microsoft.com/en-us/sql/relational-databases/databases/shrink-a-database?view=sql-server-2017