提问人:Computer Scientist 提问时间:7/4/2022 更新时间:7/4/2022 访问量:213
提高十进制列的精度和小数位数是否会影响 SQL Server 中的现有索引?
Will increasing the precision and scale of a decimal column impact existing index in SQL Server?
问:
我在 SQL Server 上有一个表,它有超过 1 亿行,并且使用量很大。我正在考虑增加其中一列的十进制精度和小数位数,该列也具有非聚集索引。更改精度/小数位数时,是否还建议在更新精度/小数位数之前删除索引,然后重新创建索引(例如,如下面的代码片段所示)。基本上不完全确定改变该领域会对指数产生什么样的影响 - 下降 + 娱乐是否矫枉过正?
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
答: 暂无答案
评论
VARCHAR