pg_search: Bringing Elasticsearch-Grade Search to PostgreSQL
summary
pg_search is a Rust PostgreSQL extension that embeds Tantivy into PostgreSQL via Custom Scan API and planner hooks (set_rel_pathlist_hook, create_upper_paths_hook) to intercept @@@ queries and push BM25 scoring, faceting and aggregations into an on-disk index stored in Postgres block storage with MVCC-aware directories. TopN execution and columnar fast fields push ORDER BY/LIMIT and GROUP BY into the index, yielding sub-100 ms queries at millions of rows — measured 81 ms vs 38,797 ms in Neon benchmarks — and removes the need for separate Elasticsearch infrastructure.
AI-written summary · about
chapters (10)
- 0:00Introduction and speaker background
- 1:08Full text search basics
- 3:37Current Postgres full text search
- 8:11Limitations of Postgres ranking
- 10:18Introducing PG Search
- 14:11Querying the PG Search index
- 15:56Top K search performance
- 19:08Top K with facets
- 21:13Query pushdown and ranking control
- 22:59Summary and benefits
related talks
28mElasticsearch-Quality Full-Text Search in Postgres via Tantivy
41mPostgreSQL is (probably) all you need
34mFull-Text Search in PostgreSQL
21mTorus: PostgreSQL Search in Ecto
42mYou don't need Elasticsearch! Fuzzy Search with PostgreSQL and Spring Data
24mSearch From the Ground Up
52mVector search is now boring, but PostgreSQL has ways to go
27mMulti-table Full Text Search with Postgres
