Vector Database Fundamentals
By Marcin Piekarski builtweb.com.au · Last Updated: 11 February 2026
TL;DR: Vector databases store and search embeddings efficiently. Learn how they work, when to use them, and popular options.
TL;DR
Vector databases store embeddings and enable fast similarity search. Essential for RAG, recommendations, and semantic search at scale.
What is a vector database?
Definition:
A database optimized for storing and searching high-dimensional vectors (embeddings).
Why not regular databases?
- Regular DBs: Exact match, keyword search
- Vector DBs: Similarity search, semantic matching
- Vector DBs: Optimized for high-dimensional data
How they work
Index creation:
- Generate embeddings for documents
- Store vectors with metadata
- Build efficient index (HNSW, IVF, etc.)
Search:
- Convert query to embedding
- Find k nearest neighbors
- Return similar items
Vector similarity search
Nearest neighbor search:
- Find items closest to query vector
- Measure: cosine similarity, dot product, L2 distance
Example:
- Query: "How to fix a leak?"
- Returns: Documents about plumbing repairs
- Even if exact words don't match
Popular vector databases
Pinecone:
- Managed service
- Easy to use
- Auto-scaling
- Paid
Weaviate:
- Open source or managed
- Multi-modal support
- Hybrid search
- Self-host or cloud
Qdrant:
- Open source
- Rust-based (fast)
- Good filtering
- Self-host or cloud
Chroma:
- Lightweight
- Great for prototyping
- Open source
- Embedded mode
Milvus:
- Open source
- Highly scalable
- Enterprise features
Pgvector (Postgres extension):
- Add vectors to existing Postgres
- Familiar SQL interface
- Good for small-medium scale
Key features
Metadata filtering:
- Search within filtered subset
- "Find similar docs from 2024"
Hybrid search:
- Combine vector + keyword search
- Best of both worlds
Multi-tenancy:
- Isolate data by user/org
- Important for SaaS
Scalability:
- Millions-billions of vectors
- Distributed architecture
When to use vector databases
Good for:
- RAG systems (document retrieval)
- Semantic search
- Recommendation engines
- Duplicate detection
- Anomaly detection
Overkill for:
- Small datasets (< 10K items)
- Exact match search
- Simple keyword search
Implementation example
import pinecone
from openai import OpenAI
# Initialize
pinecone.init(api_key="...")
index = pinecone.Index("my-index")
openai_client = OpenAI()
# Index document
text = "How to reset password..."
embedding = openai_client.embeddings.create(
input=text,
model="text-embedding-3-small"
).data[0].embedding
index.upsert([("doc1", embedding, {"text": text})])
# Search
query = "forgot my password"
query_emb = openai_client.embeddings.create(
input=query,
model="text-embedding-3-small"
).data[0].embedding
results = index.query(vector=query_emb, top_k=3)
Performance optimization
Indexing algorithms:
- HNSW: Fast, accurate (most popular)
- IVF: Good for large datasets
- Product Quantization: Compress vectors
Trade-offs:
- Accuracy vs speed
- Memory vs disk
- Indexing time vs query time
Cost considerations
Managed services:
- Pay per vector stored
- Pay per query
- $50-500+/month typical
Self-hosted:
- Server costs
- Maintenance effort
- More control
Best practices
- Choose embedding model carefully
- Experiment with index parameters
- Use metadata filtering
- Monitor query performance
- Implement caching for common queries
What's next
- Embeddings Explained
- RAG Systems
- Semantic Search
Frequently Asked Questions
When should I use a vector database instead of a regular database?
Use a vector database when you need semantic search (finding items by meaning, not exact keywords), recommendation systems, RAG-based chatbots, or duplicate detection. If you only need exact-match lookups or simple keyword search, a regular database is simpler and sufficient.
Is pgvector good enough or do I need a dedicated vector database?
pgvector is great for small to medium workloads (up to a few million vectors) and especially convenient if you already use PostgreSQL. For larger scale, higher query throughput, or advanced features like hybrid search, a dedicated vector database like Qdrant or Pinecone is a better fit.
How do I choose between Pinecone, Weaviate, and Qdrant?
Pinecone is the easiest to start with as a fully managed service. Weaviate excels at hybrid search combining keywords and vectors. Qdrant offers excellent filtering and self-hosting options. Choose based on your team's operational capacity and specific search requirements.
What embedding model should I use with a vector database?
OpenAI's text-embedding-3-small is a solid default for text. For cost-sensitive applications, open-source models like sentence-transformers work well. Match your embedding model to your use case and test with your actual data before committing.
Was this guide helpful?
Your feedback helps us improve our guides
About the Authors
Marcin Piekarski· Frontend Lead & AI Educator
Marcin is a Frontend Lead with 20+ years in tech. Currently building headless ecommerce at Harvey Norman (Next.js, Node.js, GraphQL). He created Field Guide to AI to help others understand AI tools practically—without the jargon.
Credentials & Experience:
- 20+ years web development experience
- Frontend Lead at Harvey Norman (10 years)
- Worked with: Gumtree, CommBank, Woolworths, Optus, M&C Saatchi
- Runs AI workshops for teams
- Founder of builtweb.com.au
- Daily AI tools user: ChatGPT, Claude, Gemini, AI coding assistants
- Specializes in React ecosystem: React, Next.js, Node.js
Areas of Expertise:
Prism AI· AI Research & Writing Assistant
Prism AI is the AI ghostwriter behind Field Guide to AI—a collaborative ensemble of frontier models (Claude, ChatGPT, Gemini, and others) that assist with research, drafting, and content synthesis. Like light through a prism, human expertise is refracted through multiple AI perspectives to create clear, comprehensive guides. All AI-generated content is reviewed, fact-checked, and refined by Marcin before publication.
Transparency Note: All AI-assisted content is thoroughly reviewed, fact-checked, and refined by Marcin Piekarski before publication.
Key Terms Used in This Guide
Embedding
A list of numbers that represents the meaning of text, images, or other data. Similar meanings produce similar numbers, so computers can measure how 'close' two concepts are.
Vector Database
A specialized database designed to store and search embeddings—numerical representations of text, images, or other data. It finds similar items by comparing how close their vectors are in mathematical space.
Related Guides
Fine-Tuning Fundamentals: Customizing AI Models
IntermediateFine-tuning adapts pre-trained models to your specific use case. Learn when to fine-tune, how it works, and alternatives.
8 min readRetrieval Strategies for RAG Systems
IntermediateRAG systems retrieve relevant context before generating responses. Learn retrieval strategies, ranking, and optimization techniques.
7 min readSemantic Search: Search by Meaning, Not Keywords
IntermediateSemantic search finds results based on meaning, not exact keyword matches. Learn how it works and how to implement it.
6 min read