SQL Server:如果我总是阅读“群集”行,那么群集,非唯一索引是否可以提高性能?

时间:2023-01-18 02:48:05

I have a table [groupmembers] with three columns:

我有一个表[groupmembers]有三列:

[dn] NVARCHAR(255)
[objectGUID] NVARCHAR(38)
[member] NVARCHAR(255)

The source of the data is a table where values are stored like such:

数据源是一个表,其中值存储如下:

<dn>,<objectGUID>,<member|member|member|member|member>

I have an SSIS package which splits out each of the delimited values for [member] and writes a new row for each member, but keeping the same [dn] and [objectGUID].

我有一个SSIS包,它分割出[member]的每个分隔值,并为每个成员写一个新行,但保持相同的[dn]和[objectGUID]。

So, all of the rows containing the members of each [dn]:[objectGUID] pair will always be written sequentially. The table will be truncated every time it is loaded.

因此,包含每个[dn]:[objectGUID]对成员的所有行将始终按顺序写入。每次加载时都会截断该表。

The [dn] and [objectGUID] are different unique values representing the same source object. I have them both because two different applications will each use one to query for [member]. Furthermore, the queries against [dn] OR [objectGUID] will (nearly) always return every associated [member].

[dn]和[objectGUID]是表示相同源对象的不同唯一值。我有他们两个因为两个不同的应用程序将使用一个来查询[成员]。此外,针对[dn] OR [objectGUID]的查询将(几乎)总是返回每个关联的[成员]。

Due to the fact that the [members] will (nearly) always be returned together, would it make sense to create a clustered index on one of [dn] or [objectGUID]?

由于[成员]将(几乎)总是一起返回的事实,在[dn]或[objectGUID]之一上创建聚簇索引是否有意义?

My assumption is that if the rows are written together, clustered with their like values, and read together, that the performance would be better than with a non-clustered index.

我的假设是,如果将行一起写入,使用它们的相似值进行聚类并一起读取,那么性能将比使用非聚集索引更好。

1 个解决方案

#1


0  

To me it makes sense to put the CI on dn,objectGUID.

对我来说,将CI放在dn,objectGUID上是有意义的。

#1


0  

To me it makes sense to put the CI on dn,objectGUID.

对我来说,将CI放在dn,objectGUID上是有意义的。