Introduction
Why pg-smart-search exists and when to use it. Compare search tiers and understand the core philosophy.
Introduction
pg-smart-search is a Node.js search engine SDK that lives entirely inside your PostgreSQL database. It is designed for developers who want search quality comparable to specialized engines but refuse to maintain separate infrastructure.
Who is this for?
- Startups & SMBs who can't justify a $500/mo ElasticSearch cluster.
- Enterprise Backend Engineers who need strict data sovereignty (GDPR, HIPAA).
- Node.js/TypeScript developers looking for a native, type-safe search integration.
Note: tier doesn't switch automatically based on dataset size — you set it explicitly in
TrigramEngineConfig (default STANDARD); the table below is sizing guidance, not
autodetection.
Search Tiers Comparison
| Tier | Dataset Size | Engine Features | Indices Required |
|---|---|---|---|
| LITE | < 100k rows | Basic ILIKE | None |
| STANDARD | 100k - 1M rows | Hedged FTS + ILIKE/trigram | GIN (FTS) + GiST/GIN (trigram) |
| ADVANCED | > 1M rows | word_similarity ranking | GiST/GIN pg_trgm (not RUM — see Search Tiers) |
| VECTOR | Semantic | OpenAI/Gemini + pgvector (HNSW) | pgvector HNSW |
Benchmarks
Measured with npm run bench:real against one specific PostgreSQL 16 instance, 1M rows,
GIN + GiST indexes — not a universal number, and not directly comparable to your hardware
or dataset:
- Cold Latency (avg): ~56ms, P95: ~204ms
- Cached Latency (avg): ~0.02ms
- Algorithmic Scaling: varies by tier — see Search Tiers for which parts are actually index-served vs. in-memory sorted.
Run npm run bench:real against your own schema and data rather than trusting numbers
measured on someone else's machine.
pg-smart-search Documentation
High-performance Search SDK for PostgreSQL. Parallel/hedged search strategies, smart fallbacks, and zero extra infrastructure. Replace ElasticSearch with pure Postgres.
Installation
How to install pg-smart-search in your Node.js or TypeScript project using npm, yarn, or pnpm.