增加小数列的精度和比例会影响SQL Server中现有索引吗?
我在SQL Server上有一个超过1亿行的SQL Server,并且使用了大量使用。我正在考虑增加其中一列之一的小数精度和比例,该列也具有非群集索引。在更改精度/比例时,是否还建议在更新精度/比例之前删除索引,然后再重新创建索引(例如,在下面的摘要中类似)。基本上,不完全确定改变该领域的影响会对指数产生什么样的影响 - Drop + Recreation是过度的?
DROP INDEX IF EXISTS [IX_Index] ON [dbo].[TableName]
ALTER TABLE dbo.[TableName]
ALTER COLUMN DecimalField DECIMAL(14, 9) NOT NULL
IF NOT EXISTS(SELECT * FROM sys.indexes WHERE name='IX_Index' AND object_id = OBJECT_ID('dbo.TableName'))
BEGIN
CREATE NONCLUSTERED INDEX [IX_Index] ON [dbo].[TableName]
(
DecimalField ASC
) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF)
END
I have a table on SQL Server with over 100 million rows and quite heavily used. I'm looking at increasing the decimal precision and scale of one of the columns, which also has a non-clustered index. When changing precision/scale, is it also recommended to drop the index before updating precision/scale, followed by recreating an index (something like in the snippet below for example). Basically not entirely sure what sort of impact altering the field would have on the index - is the drop + recreation an overkill?
DROP INDEX IF EXISTS [IX_Index] ON [dbo].[TableName]
ALTER TABLE dbo.[TableName]
ALTER COLUMN DecimalField DECIMAL(14, 9) NOT NULL
IF NOT EXISTS(SELECT * FROM sys.indexes WHERE name='IX_Index' AND object_id = OBJECT_ID('dbo.TableName'))
BEGIN
CREATE NONCLUSTERED INDEX [IX_Index] ON [dbo].[TableName]
(
DecimalField ASC
) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF)
END
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论