Hi Alvaro,
On 01/08/2018 03:36 PM, Alvaro Herrera wrote:
> Jesper Pedersen wrote:
>
>> Maybe a warning for existing indexes on the same column(s), but with a
>> different type, should be emitted during ATTACH, e.g.
>
>> [detach one partition, replace index with a different one, attach
>> partition]
>
>> Of course, this could also fall under index maintenance and no warning
>> emitted. Docs have "Each partition is first checked to determine whether an
>> equivalent index already exists," so it is covered.
>
> Yeah, I'm of two minds about this also -- in the initial versions I had
> a code comment wondering exactly about having a hash index in a
> partition attached to a btree index on parent.
>
> As another example, having a documents table with two partitions (one
> "long term archival" and other "documents currently being messed with")
> you could have a text search index which is GIN in the former and GiST
> in the latter. There is a performance argument for doing it that way,
> so it's not merely academic.
>
> Anyway, while I think attaching an index that doesn't match the
> properties of the index on parent can be a useful feature, on the other
> hand it could be surprising (you end up losing an index because it was
> matched during attach that you didn't think was going to be matched).
> One idea would be to have a way to specify at ATTACH time what to do
> about indexes when they don't match exactly, but I think the user
> interface would be pretty messy: exactly how different do you want to
> allow the indexes to be? Is an index having one more column than the
> one in parent good enough? I think the answer to this is mostly a
> judgement call, and I'd rather not spend my time debating those.
>
Yeah, agreed - lets leave as is.
Migrating an index to another type would mean to drop the top-level
definition anyway.
Best regards,
Jesper