Vector Databases: Why They Power Modern AI Apps
If you’ve read anything about building AI apps, you’ve seen the term vector database. It sounds intimidating, but the idea is simple — and once it clicks, a lot of modern AI makes sense.
First, what’s a vector (embedding)?
An embedding is a way of turning text (or an image, or audio) into a list of numbers that captures its meaning. Two pieces of text with similar meaning end up with similar numbers — even if they use completely different words.
For example, “How do I reset my password?” and “I forgot my login” would have embeddings that sit close together, because they mean nearly the same thing.
What a vector database does
A vector database stores these embeddings and is extremely good at one job: finding the items whose vectors are closest to a given query vector. This is called similarity search (or “nearest-neighbor” search).
So instead of matching keywords like a traditional search, it matches meaning.
Why traditional databases aren’t enough
A normal database is great at exact matches: “find the row where email = x.” But it can’t answer “find the documents that mean something similar to this question.” Comparing millions of vectors quickly needs specialized indexing — which is exactly what vector databases are built for.
How “closeness” is actually measured
When we say two vectors are “close,” we usually mean their cosine similarity is high — the angle between them is small. Each embedding is a point in a space with hundreds or thousands of dimensions, and meaning-similar items cluster together. You don’t need the math to use it, but the intuition helps: the database is measuring directions of meaning, not string overlap.
The speed trick: approximate search
Comparing a query against millions of vectors one by one would be far too slow. Vector databases use Approximate Nearest Neighbor (ANN) indexes — algorithms like HNSW — that trade a tiny bit of accuracy for enormous speed, returning great matches in milliseconds. This indexing is the real engineering that separates a vector database from a plain table of numbers.
Where they’re used
- RAG systems — retrieving the right documents to feed an AI (see our guide on RAG).
- Semantic search — search that understands intent, not just keywords.
- Recommendations — “items similar to this one.”
- Deduplication & clustering — grouping similar content automatically.
Popular options
There are many good choices today — some are dedicated databases, others are extensions to databases you already use:
- Pinecone, Weaviate, Qdrant, Milvus — dedicated vector databases.
- pgvector — adds vector search to PostgreSQL, so you can keep everything in one familiar database.
For most projects starting out, pgvector is a great, low-friction choice because you probably already use Postgres.
The mental model
Think of a vector database as a library organized by meaning instead of by title. You walk in with an idea, and it instantly hands you the most relevant items — even if you didn’t know their exact names. That capability is the quiet engine behind most of today’s useful AI applications.
Frequently Asked Questions
What is a vector database in simple terms?
It's a database that stores the 'meaning' of text, images or audio as lists of numbers (embeddings) and is optimised to instantly find the items whose meaning is closest to your query. Instead of matching keywords, it matches meaning.
Do I need a vector database, or can I use PostgreSQL?
You may not need a separate one. The pgvector extension adds vector search to PostgreSQL, so small and medium projects can keep everything in one familiar database. Dedicated stores like Pinecone, Weaviate, Qdrant or Milvus make sense at large scale or very high query volumes.
What is similarity search?
Similarity search (or nearest-neighbor search) finds the stored vectors closest to a query vector, usually measured by cosine similarity. It's what lets a vector database return the most relevant results by meaning rather than exact keywords.