Vector Databases & Embeddings Explained for Developers: pgvector vs Chroma in Production
How text turns into 1536-dimensional vectors, how Cosine Similarity and HNSW indexes find semantic meaning in milliseconds, and how to choose the right Vector DB.

- Vector embeddings convert text, code, or images into arrays of floating-point numbers (e.g., 768 or 1536 dimensions) where semantically similar concepts sit close together in geometric space.
- Traditional SQL `LIKE '%keyword%'` searches only match exact characters; Vector similarity search (Cosine Similarity + HNSW indexing) matches intent and meaning even when zero words overlap.
- For 90% of enterprise backend teams, PostgreSQL with `pgvector` beats standalone vector databases because it combines ACID transactions, relational joins, RBAC metadata filtering, and vector search in one engine.
1. What Is a Vector Embedding (In Plain Developer Terms)?
Imagine a 2D map where every phrase is plotted by `[Tech-Relatedness, Urgency]`. The phrase `'Production database crashed'` and `'RDS instance is down'` share zero common words—so a SQL `ILIKE` query fails completely. Yet in an embedding model's coordinate space, both phrases map to almost identical floating-point arrays like `[0.92, -0.41, 0.77, ...]` across 1,536 dimensions.
By measuring the angle between two vectors using Cosine Similarity, your backend can retrieve semantically relevant documents in under 15 milliseconds.
2. Choosing Your Vector Store: pgvector vs Chroma vs Dedicated Cloud Vector DBs
In interviews, architects will ask why you chose a specific vector database for your RAG project. Use this comparison matrix to justify your architecture:
| Feature | PostgreSQL + pgvector | ChromaDB | Dedicated Cloud Vector DB (Pinecone / Qdrant) |
|---|---|---|---|
| Architecture Type | Extension inside your existing PostgreSQL / AWS RDS instance | Lightweight open-source AI-native embedding database | Separate managed vector infrastructure service |
| Transactional Consistency | Full ACID transactions with your relational user/document tables | Separate store (requires dual-write sync logic) | Eventual consistency with primary relational DB |
| Indexing Algorithm | HNSW (Hierarchical Navigable Small World) & IVFFlat | HNSW | Proprietary / HNSW + Sparse-Dense indexes |
| Best Use Case | Production enterprise apps with <50M vectors needing SQL joins & RBAC | Fast local development, AI microservices & RAG prototyping | Massive scale (100M–1B+ vectors) with dedicated ops budgets |
3. Three Vector Search Rules Every Engineer Must Know
When implementing vector search in Spring AI or Python, never make these three beginner mistakes:
- Rule 1 — Never Mix Embedding Models on the Same Index: If you index documents with `text-embedding-3-small` (1536 dims) and query with a local `nomic-embed-text` (768 dims) model, the vector spaces are incompatible.
- Rule 2 — Always Create an HNSW Index for Production: Without an HNSW index, `pgvector` performs a sequential scan across every row ($O(N)$), which slows down dramatically past 50,000 chunks.
- Rule 3 — Combine Metadata Filtering with Vector Search: Store `tenant_id`, `document_type`, and `updated_at` as indexed columns alongside your embedding column so queries remain fast and multi-tenant safe.
Frequently Asked Questions
What is the difference between Cosine Similarity, Euclidean Distance (L2), and Dot Product?
Cosine Similarity measures the angle between two vectors (ignoring magnitude), making it ideal for text embeddings of varying lengths. When embedding vectors are normalized to unit length (like OpenAI embeddings), Dot Product and Cosine Similarity produce identical rankings.
Do I learn both pgvector and Chroma in Uncorp's Gen AI cohort?
Yes. In Week 3 of Uncorp's Gen AI Engineering: Foundation (Live Cohort), you implement vector storage, HNSW indexing, and semantic retrieval hands-on with both PostgreSQL `pgvector` and Chroma.
Naitik Tailor & Uncorp Engineering Faculty
Founder & Principal Engineering Mentors (12+ Yrs Enterprise Experience) · VIT CSE '21 · Symbiosis MBA '24 · Ex-Delhivery & Ex-Aditya Birla Capital
Continue Reading in This Topic Cluster
All 73 Guides
What is RAG in Generative AI? Complete Architecture, Vector Search & Production Workflow
Understand Retrieval-Augmented Generation from first principles: ingestion, semantic chunking, vector embeddings, HNSW search, hybrid BM25 + Cross-Encoder reranking, and citation grounding.

How LLMs Actually Work: An Engineer's Guide to Transformers, Tokens, Attention & Inference
Understand what happens inside a Large Language Model from the moment you send a prompt to the moment tokens stream back—explained for software engineers, not mathematicians.

Which AI Topics Actually Help Software Engineers Land High-Paying Jobs?
Cut through the hype: why applied Gen AI Engineering (RAG, Vector DBs, Spring AI, LangGraph, MCP, Fine-Tuning & Evals) beats theoretical ML math for 95% of software developer jobs.

