If I use:
SET pg_trgm.similarity_threshold = 0.9;
... where column % 'some string s';
PostgreSQL does an index scan on: gin (column gin_trgm_ops)
In contrast, which should be the same:
... where similarity(column, 'some string s' ) >= 0.9
That does a seqential scan instead of using the index.
From the documentation: https://www.postgresql.org/docs/11/pgtrgm.html
text % text
boolean
Returns true if its arguments have a similarity that is greater than the current similarity threshold set bypg_trgm.similarity_threshold
.
Why?