Open mgartner opened 3 months ago
This was discovered by @michae2 here: https://github.com/cockroachdb/cockroach/pull/121973#pullrequestreview-1993090966
This affects versions v22.2.0+. It has existed since trigram inverted indexes were introduced.
The optimizer produces incorrect query plans for queries with trigram similarity filters, e.g.,
col % 'foo'
, whenpg_trgm.similarity_threshold
is set to0
. These incorrect query plans produce incorrect results. For example:When
pg_trgm.similarity_threshold
is set to0
, all strings are similar:Therefore, there is no subset of trigrams in the inverted index we can scan in order to find all rows matching the filter. We'd need to scan the entire inverted index. But that would be less efficient than scanning the entire primary index, so we simply shouldn't plan an inverted index scan at all.
Jira issue: CRDB-37893