У меня есть прилично большая таблица 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'
....