绩效之间的差异指数上的两列vs有条件的索引

0

的问题

我有一个体面的大postgres表几十亿行。

然而,该表能够分配通过一项列(type)

我们应该喜欢:

一个指数有两列

create nonclustered index ix_index1 on table1(type, string_urn_id)

或一个有条件的索引

create nonclustered index ix_index1_alternative on table1(string_urn_id) WHERE type = 'type1'
create nonclustered index ix_index1_alternative2 on table1(string_urn_id) WHERE type = 'type2'
create nonclustered index ix_index1_alternative3 on table1(string_urn_id) WHERE type = 'type3'
....
database-performance postgresql
2021-10-27 02:41:08
1

最好的答案

1

没有声明 create nonclustered index 在PostgreSQL。

什么是更好地取决于该定义的"更好"。 从维持的角度看,单个的指标较好,因为你不会来创建一个新的索引只要你增加一个新的 type.

从性能的角度来看,只有一个基准与现实的数据可以告诉。 规划时间将会增加许多指标,但是,查询可能一点点好。

如果你分区的表,查询性能将减少,但可以与一个单一的分配指数 string_urn_id.

2021-10-27 07:02:43

其他语言

此页面有其他语言版本

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................