更新时间:2023-02-03 13:55:43
[有一个包含 6 个字段的聚集索引,以及单个字段上的另外两个索引.]
[there is a clustered index with 6 fields, and two other indexes on single fields.]
在不知道有关字段的任何详细信息的情况下,我会尝试找到一种方法来缩小聚集索引.
Without knowing any details about the fields, I would try to find a way to make the clustered index smaller.
使用 SQL Server,所有聚集键字段也将包含在所有非聚集索引中(作为从非聚集索引到实际数据页进行最终查找的一种方式).
With SQL Server, all the clustered-key fields will also be included in all the non-clustered indices (as a way to do the final lookup from non-clustered index to actual data page).
如果您有 6 个字段,每个 8 字节 = 48 字节,再乘以两个索引乘以 7700 万行 - 并且您会看到大量浪费的空间,这转化为很多I/O 操作(从而降低性能).
If you have six fields at 8 bytes each = 48 bytes, multiply that by two more indices times 77 million rows - and you're looking at a lot of wasted space which translates into a lot of I/O operations (and thus degrades performance).
对于聚集索引来说,它的唯一性、稳定性和尽可能小(***是单个 INT 之类的)绝对是至关重要的.
For the clustered index, it's absolutely CRUCIAL for it to be unique, stable, and as small as possible (preferably a single INT or such).
马克