Support LIKE and ILIKE index searches via contrib/pg_trgm indexes.
Tom Lane <tgl@sss.pgh.pa.us>
Support LIKE and ILIKE index searches via contrib/pg_trgm indexes. Unlike Btree-based LIKE optimization, this works for non-left-anchored search patterns. The effectiveness of the search depends on how many trigrams can be extracted from the pattern. (The worst case, with no trigrams, degrades to a full-table scan, so this isn't a panacea. But it can be very useful.) Alexander Korotkov, reviewed by Jan Urbanski
Files
| Path | Change | +/− |
|---|---|---|
| contrib/pg_trgm/expected/pg_trgm.out | modified | +90 −0 |
| contrib/pg_trgm/pg_trgm.sql.in | modified | +10 −6 |
| contrib/pg_trgm/sql/pg_trgm.sql | modified | +25 −0 |
| contrib/pg_trgm/trgm_gin.c | modified | +120 −12 |
| contrib/pg_trgm/trgm_gist.c | modified | +83 −12 |
| contrib/pg_trgm/trgm.h | modified | +18 −4 |
| contrib/pg_trgm/trgm_op.c | modified | +275 −11 |
| contrib/pg_trgm/uninstall_pg_trgm.sql | modified | +3 −3 |
| doc/src/sgml/pgtrgm.sgml | modified | +16 −2 |