watermarkchurch/wcc-contentful

Postgres store: Use array operators instead of ANY() on links

Opened this issue · 0 comments

Joining entries using the ANY(t.links) column actually makes it impossible to use an index to do that join, as explained in this Stack Overflow:
https://stackoverflow.com/a/29245753/2192243

Instead of using ANY, we need to use the Array Contains operator @> and then apply a GIN index to the links column:

CREATE INDEX IF NOT EXISTS contentful_raw_links ON contentful_raw USING GIN (links array_ops);