vsql_trgm is a port of PostgreSQL’s pg_trgm. It breaks a string into
three-character pieces and scores two strings by how many pieces they share, so
a misspelled search term still finds its row. Use it when LIKE is too strict
and full-text search is too coarse.
Install
vsql_trgm.veb is already in the server’s lib/veb/ directory if you installed
VillageSQL with the install script, the Docker image, or a release tarball.
Install it into the server with one statement:
What it adds
It adds three families of function. The plain family compares two whole strings. The word family finds the best-matching substring of the second string. The strict word family does the same but aligns on word boundaries. Each family has its own default threshold.Example
Build a small name table:PostgreSQL’s
set_limit() has no counterpart here, because a VEF function
keeps no session state. Pass the threshold you want to
trgm_similar_threshold() instead. A similarity filter also reads every row,
so measure it before running one against a large table.See also
- Trigram similarity in MySQL — thresholds, ranking, and what it costs on a large table
- Fuzzy string matching — phonetic codes and edit distance as alternatives
- Full-text search — the right tool for documents rather than names
- Install extensions — how
INSTALL EXTENSIONworks and where the server looks for a bundle - Available extensions — the full catalog
- villagesql/vsql-trgm — source, build instructions, and the known limitations

