Vector Databases
A vector database stores embeddings and is built to quickly find the ones most similar to a given query vector, at scale.
Prerequisites
What Is a Vector Database?
A vector database stores embeddings and is optimized for one core operation: given a query vector, find the stored vectors most similar to it, quickly, even across millions of entries.
Documents
Raw SourceContent before it becomes searchable.
Embeddings
Vector FormTurns content into comparable numbers.
Vector Database
Optimized StorageBuilt for fast similarity search at scale.
Query
Starting PointWhat the user is looking for.
Query Embedding
Same Vector SpaceEncoded the same way as the stored content.
Similarity Search
Core OperationFinds the closest stored vectors, fast.
Relevant Vectors / Documents
Ranked MatchesThe most similar entries, even among millions.
Important
A vector database is not simply "a database for AI." It is a specialized store optimized for similarity search over vectors — a different access pattern from looking up a record by an exact key.
How Similarity Search Works
Comparing a query vector against every single stored vector one by one — an exact nearest-neighbor search — becomes slow once you have a large collection. Vector databases instead typically use approximate nearest-neighbor (ANN) search: indexing structures that trade a small amount of accuracy for a large gain in speed, returning results that are very likely, but not mathematically guaranteed, to be the closest matches.
- Indexing
- The structure built over stored vectors ahead of time so similarity search can run quickly instead of scanning everything.
- Metadata
- Structured information attached to each vector — like source, date, or permissions — used to filter results alongside similarity.
- Retrieval
- The overall step of finding and returning the most relevant stored content for a query, which vector search is one way to perform.
Why Metadata Filtering Matters
Similarity alone often is not enough. A production system usually needs to combine "find vectors similar to this query" with filters like "only from this customer's documents" or "only published in the last year." Metadata filtering applies those constraints alongside the similarity search, rather than similarity search running in isolation.
Common Mistakes
Treating it as a general-purpose database
It excels at similarity search; it is usually not the right tool for transactional workloads or complex relational queries.
Ignoring metadata filtering
Pure similarity search with no filtering can surface content that is relevant in meaning but wrong in context — the wrong customer, an outdated version, or restricted access.
Assuming one vector database is universally best
The right choice depends on scale, latency needs, filtering requirements, and how it fits your existing infrastructure — not a single "best" answer.
Interview Question
What is a vector database, and how is it different from a traditional database?
A vector database stores embeddings and is optimized to find the vectors most similar to a query vector, quickly, even at large scale — typically using approximate nearest-neighbor search rather than an exact, exhaustive comparison. That's a different access pattern from a traditional database, which is optimized for exact lookups and relational queries. In practice, vector databases also need metadata filtering, so similarity search can be combined with constraints like source, date, or access permissions rather than running in isolation.
What an interviewer may ask next
- Why do vector databases typically use approximate rather than exact nearest-neighbor search?
- Why is metadata filtering important alongside similarity search?
- When would a vector database not be the right tool?
Explain It in 30 Seconds
A vector database stores embeddings and is built to quickly find the ones most similar to a query vector, even across millions of entries — usually using approximate nearest-neighbor search rather than comparing against everything exactly. It’s not a general-purpose database; it’s specialized for similarity search, and real systems typically pair that search with metadata filtering so results respect things like source or access permissions.