pg_tre
A native PostgreSQL 18+ index access method for fast approximate (fuzzy) regular-expression matching over text columns.
pg_tre turns the classic "find text that looks like this, maybe with a typo" problem into a SQL-composable indexed query. A three-tier filter funnel (range bloom → trigram posting trees → per-tuple bloom) narrows the candidate set before any heap recheck, with the TRE library performing the exact edit-distance match.
SELECT id FROM docs
WHERE body %~~ tre_pattern('(error){~1}.*(42[0-9]){~0}', 1);
-- Bitmap Index Scan on docs_tre → sub-millisecond on 10k rows.
Where to start
- User Guide — installation, operators, query syntax, tuning, and worked examples. Start here.
- Design — architecture of the three-tier funnel and the on-disk structures.
- On-disk page format — byte-level page layout reference.
- Performance — measured numbers and methodology.
- Testing — the regression / sanitizer / stress apparatus.
Project links
- Source & issues: https://codeberg.org/gregburd/pg_tre
- GitHub mirror: https://github.com/gburd/pg_tre
- License: MIT (bundles TRE under BSD-2-Clause)