Solutions · Vector search & RAG
Vector search on the database you already trust.
pgvector turns Postgres into a perfectly good vector store for RAG, semantic search, and recommendations. Index with IVFFlat for speed or HNSW for recall — both shipped enabled.
Why Postgres for vectors
A vector store does not need to be a separate product. pgvector adds a `vector` column type and ANN indexes to Postgres so you can run similarity searches in the same database that holds the rest of your application state — filter by tenant, join with metadata, paginate with cursors, all in one query. For most RAG workloads up to tens of millions of vectors, this is simpler, cheaper, and easier to operate than a dedicated vector database.
IVFFlat for low-latency ANN
HNSW for high recall
Hybrid queries
Multiple distance metrics
Code sample
CREATE EXTENSION IF NOT EXISTS vector;
CREATE TABLE chunks (
id BIGSERIAL PRIMARY KEY,
doc_id BIGINT NOT NULL,
body TEXT NOT NULL,
embedding vector(1536) NOT NULL
);
-- IVFFlat index: 100 lists is a good starting point for ~1M rows.
CREATE INDEX chunks_embedding_ivfflat
ON chunks USING ivfflat (embedding vector_cosine_ops)
WITH (lists = 100);
-- At query time, set the number of lists to probe.
SET ivfflat.probes = 10;
-- Find the 5 nearest chunks within a specific document.
SELECT id, body
FROM chunks
WHERE doc_id = 42
ORDER BY embedding <=> $1::vector
LIMIT 5;Indexing strategy
Start with IVFFlat at `lists = sqrt(rows)` and `probes = lists/10`. Measure recall on a held-out set. If recall is too low for your use case, raise `probes` (slower queries, higher recall) or switch to HNSW. HNSW indexes are slower to build but give you better recall at the same latency on 1k+ dim embeddings.
Examples
- RAG chatbots — index your knowledge base, retrieve top-K chunks per query
- Semantic product search — embed product titles + descriptions, search by intent
- Document deduplication — find near-duplicates above a similarity threshold
- Recommendation systems — user-embedding × item-embedding nearest neighbors
Frequently asked questions
How many vectors before I need a dedicated vector DB?
Do I need to rebuild the index when I insert new rows?
Can I store metadata alongside the vector?
Ship vector search on the database you know.
pgvector is enabled by default on every Luceris Postgres cluster, including the Free tier.