SQL Server调优系列进阶篇 - 如何重建数据库索引
2015-05-13 18:35
393 查看
随着数据的数据量的急剧增加,数据库的性能也会明显的有些缓慢这个时候你可以考虑下重建索引或是重新组织索引了。
DBCC SHOWCONTIG('表名') 可以查看当前表的索引碎情况。
方法二:
DBCC SHOWCONTIG('表名') 可以查看当前表的索引碎情况。
重建索引
方法一:DECLARE @name varchar(100) DECLARE authors_cursor CURSOR FOR Select [name] from sysobjects where xtype='u' order by id OPEN authors_cursor FETCH NEXT FROM authors_cursor INTO @name WHILE @@FETCH_STATUS = 0 BEGIN DBCC DBREINDEX (@name, '', 90) /*--填充因子:90,建议60-90之间,100的查询性能最好,但插入数据后会导致索引页迁移会影响修改的性能.*/ FETCH NEXT FROM authors_cursor INTO @name END Close authors_cursor Deallocate authors_cursor
方法二:
DECLARE tables CURSOR for select name from sysobjects where xtype='U' DECLARE @table_name char(128) Open tables Fetch next from tables into @table_name While @@fetch_status=0 Begin EXECUTE ('ALTER INDEX ALL ON ' + @table_name + ' REBUILD') Fetch next from tables into @table_name End Close tables Deallocate tables
相关文章推荐
- SQL Server调优系列进阶篇(如何维护数据库索引)
- SQL Server调优系列进阶篇(如何维护数据库索引)
- SQL Server调优系列进阶篇(如何维护数据库索引)
- SQL Server调优系列进阶篇 - 如何维护数据库索引
- SQL Server调优系列进阶篇(如何维护数据库索引)
- SQL Server调优系列进阶篇(如何维护数据库索引)
- SQL Server调优系列进阶篇(如何维护数据库索引)
- SQL Server调优系列进阶篇(如何索引调优)
- SQL Server调优系列进阶篇(如何索引调优)
- SQL Server调优系列进阶篇(如何索引调优)
- SQL Server调优系列进阶篇(如何索引调优)
- SQL Server调优系列进阶篇(如何索引调优)
- SQL Server调优系列进阶篇 - 如何索引调优
- SQL Server调优系列进阶篇(如何索引调优)
- SQL Server调优系列进阶篇(如何索引调优)
- SQL Server调优系列进阶篇(如何索引调优)
- Oracle如何批量重建数据库索引
- SQL Server 2000数据库中如何重建索引
- SQLServer2000数据库中如何重建索引
- SQL Server调优系列基础篇(索引运算总结)