PostgreSQL & GenAI
PostgreSQL stores application data and, via pgvector, can store embeddings in the same database rather than a separate system.
Prerequisites
Overview
A team already running PostgreSQL for application data can add the pgvector extension and store embeddings there too, avoiding the operational overhead of running a second, dedicated vector database — a reasonable tradeoff below a certain scale.
Where It Fits
Application Data
PostgreSQL
One databasepgvector (Embeddings)
Retrieval
Key Points
- One system to operate
- Storing embeddings alongside application data avoids running and securing a second database system.
- Joins with relational data
- A retrieval query can join vector similarity with normal relational filters — e.g. by tenant or permission — in one query.
- Scale ceiling
- At very high vector volume or query rate, a dedicated vector database is usually a better fit than pgvector.
Interview Question
When would you use pgvector instead of a dedicated vector database like Pinecone?
When PostgreSQL is already the application’s primary database and vector volume is moderate, pgvector avoids operating a second system and lets a query join vector similarity with normal relational filters in one place. Past a certain scale or when specialized indexing/filtering is needed, a dedicated vector database is usually the better fit.
Explain It in 30 Seconds
PostgreSQL with the pgvector extension lets a team store embeddings in the same database as their application data, useful when Postgres is already central and vector volume doesn’t yet justify a dedicated vector database.
Real-World Stack
Technologies commonly used to implement this in production.