pgtrgm
pg_trgm is a PostgreSQL extension that provides trigram-based text search capabilities and indexing. It generates trigrams—substrings of length three—from text and uses them to approximate string similarity. This enables efficient fuzzy matching, approximate string comparisons, and near-duplicate detection, particularly for pattern-based queries such as LIKE, ILIKE, and SIMILAR TO.
The extension offers support for index-based search using both GiST and GIN index types. The trigram operators
Usage typically begins with enabling the extension and creating trigram-based indexes. Example: CREATE EXTENSION pg_trgm; CREATE
Considerations include increased storage and maintenance costs for trigram indexes and the need to tune the