Index for a complex similarity query Postgres
Your only chance is to index all possible conditions, perhaps PostgreSQL will use bitmap operations to cover the ORs. Perhaps it will think that a sequential scan is cheaper and go for that.

CREATE INDEX ON mymatview (lower(d));

CREATE INDEX ON mymatview USING gin (d gin_trgm_ops) WHERE length(d) &gt; 4;