简体   繁体   English

增加varchar字段的大小时SQL Server 2005索引重建

[英]SQL Server 2005 Index rebuild when increasing the size of a varchar field

I have a 12 varchar(50) fields in a table of about 90 million rows that I need to increase to varchar(100) in length. 我在大约9000万行的表中有12个varchar(50)字段,需要将其长度增加到varchar(100)。 Each of these fields has an index (with only the one field as a member). 这些字段中的每个字段都有一个索引(只有一个字段作为成员)。 If I increase the length of the varchar fields, will the indexes either need to be rebuilt (or would be rebuilt automatically), or would the statistics become out of date? 如果增加varchar字段的长度,是否需要重建索引(或将自动重建索引),或者统计信息会过时?

I don't have a reasonably sized test system test (or perhaps dont know how to see if the indexes were rebuilt or statistics need to be recomputed). 我没有适当大小的测试系统测试(或者也许不知道如何查看是否重建了索引或需要重新计算统计信息)。

Thanks 谢谢

Statistics are based on what is in columns, not their size, so your statistics won't become out of date. 统计信息基于列中的内容而不是其大小,因此您的统计信息不会过时。

Bear in mind that sometimes when you alter a column, SQL server will add a new column to the table and drop the existing one, so it will have to rebuild the index in that case anyway. 请记住,有时当您更改一列时,SQL Server会在表中添加一个新列并删除现有的列,因此无论如何都必须重建索引。

Despite searching I can't categorically say whether you have to rebuild indexes, but I would rebuild regardless (as this should be occuring as part of your normal maintenance, assuming this table is not read-only or very low writes) 尽管进行了搜索,但我无法明确地说是否必须重建索引,但是无论如何我都将重建(因为这应该是正常维护的一部分,假设此表不是只读的或写得很少)

BTW, having a seperate index on each of those columns might not be optimal. 顺便说一句,在那些列的每一列上都有单独的索引可能不是最佳的。 Have you profiled your query workload? 您是否配置了查询工作量?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM