我有一个体面的大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'
....