PostgreSQL · Solution
Vector search and RAG
Store embeddings next to your relational data and query them with pgvector — no separate vector database to run.
How it works
Enable the pgvector extension, add a vector column sized to your embedding model, and index it with IVFFlat for approximate nearest-neighbor search.
pgvector built in
Enable the extension and store embeddings as a native column type.
Approximate nearest neighbor
Index with IVFFlat and tune recall with probes.
Code sample
sqlEnable pgvector and index a 1536-dim embedding table
-- or install pgvector from the Extensions tab in the dashboardCREATE 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, bodyFROM chunksWHERE doc_id = 42ORDER BY embedding <=> $1::vectorLIMIT 5;Sizing
An IVFFlat index with 100 lists is a reasonable starting point for roughly a million rows; adjust lists and probes as your embedding table grows.
Examples
- Document search prototypes
- Internal knowledge-base demos
- Retrieval-augmented chat experiments
Frequently asked questions
Do I need a separate vector database?
No — pgvector runs inside the same PostgreSQL database as the rest of your schema.
Which embedding sizes are supported?
Any fixed dimension you declare on the column, such as 1536 for common embedding models.
How many vectors before I need a dedicated vector DB?
Most workloads under ~10M vectors at 1536 dimensions run comfortably on a single Postgres database. Above that, consider sharding by tenant or moving the embedding column to a dedicated database.
Do I need to rebuild the index when I insert new rows?
No — pgvector indexes support incremental inserts. Rebuild only when you change the lists parameter or move from IVFFlat to HNSW.
Can I store metadata alongside the vector?
Yes — that is the whole point of pgvector over a dedicated store. Add columns, foreign keys, partitions; filter, join, paginate as usual.
Add vector search to your schema.
pgvector is available on every Luceris Cloud PostgreSQL database, including the Free tier — install it from the Extensions tab. Luceris Cloud is for development environments and not for production.