subql icon indicating copy to clipboard operation
subql copied to clipboard

@index(unique: true) and historical should have exclusion constraints set.

Open stwiname opened this issue 1 year ago • 1 comments

Description

This is a follow up issue to https://github.com/subquery/subql/issues/1518. When historical is enabled and @index(unique: true) is set on an entity field a GiST index is used with _block_height. But GiST doesn't support unique indexes so the fields on this entity will not be unique.

We should set exclusion constraints on the table to enforce the uniqueness

stwiname avatar May 08 '23 03:05 stwiname

I think unique index doesn't offer more efficiency than a normal index, so we can safely say it is for fool-proofing. In that case, we can ignore unique:true or refuse it. I'm worried more exclusion constraints will have performance impact.

ianhe8x avatar May 09 '23 23:05 ianhe8x