Ordinary databases are good at exact matches: find the order with this number, the customer with this email. A vector database answers a different question: which stored items are closest in meaning to this one? It does that by storing embeddings, lists of numbers that place similar content near each other, and searching them quickly. Almost every system that lets a language model answer from company documents uses one, so the choice of vector database is a common line in AI build quotes.
How it works
Content is first split into passages and converted to embeddings by an embedding model. Each embedding is stored with an ID, the original text and metadata such as source, date or the users allowed to see it. At query time, the question is embedded with the same model and the database returns the nearest stored vectors, usually measured by cosine similarity.
Searching millions of vectors one by one would be slow, so vector databases build approximate nearest-neighbour indexes, such as HNSW, that trade a small amount of accuracy for large gains in speed. Most also support metadata filters ("only documents for this customer account"), which is how access control is enforced in retrieval.
Options range from dedicated managed services such as Pinecone, Weaviate and Qdrant to vector extensions on existing databases, notably pgvector for PostgreSQL, which is available on platforms like Supabase. For small collections even an in-memory index can be enough.
What it means for cost
The vector database is rarely the largest cost in a retrieval-augmented generation build, but the choice affects running costs and maintenance:
- Managed or self-hosted. A managed service is quicker to start and bills by storage and queries; self-hosting avoids that bill but adds operations work.
- Existing stack. If the business already runs PostgreSQL, adding pgvector can avoid a new vendor entirely.
- Volume and freshness. Large collections and frequently changing documents raise storage, indexing and re-embedding costs.
Ask a builder why they chose a given store, how the index is updated when documents change, and what it would take to move to another one later. Live figures for retrieval builds are on the document search and RAG cost page.
Common questions
Does every RAG build need a dedicated vector database?
Often not at small or moderate scale. PostgreSQL with pgvector, or the vector features in many existing databases, handles a great many business use cases. A dedicated service becomes attractive with very large collections, heavy query traffic or a wish to avoid running database infrastructure.
Can a vector database replace keyword search?
Not entirely. Vector search is good at meaning but can miss exact terms such as product codes or names. Many production systems combine both in hybrid search.