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

允我心安 提交于 2019-12-12 04:59:22

问题


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. 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?

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


回答1:


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.

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?



来源:https://stackoverflow.com/questions/3868911/sql-server-2005-index-rebuild-when-increasing-the-size-of-a-varchar-field

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!