What is a vector database? Explained with a library shelved by topic
A vector database stores embeddings, numbers that describe meaning, and finds the items closest to a question. Explained with a library that shelves books by topic, not by title.
- Author
Umair Mateen- Published
- Reading time
- 5 min
- Category
- AI
In one sentence: A vector database is a store built to keep embeddings, the lists of numbers that describe what a piece of content means, and to find the stored items whose meaning is closest to a question, like a library that shelves books by topic so related books sit side by side.
The everyday picture
Most libraries shelve books in a fixed order, such as by title or author. That works when you know the exact title. It fails when you only know what you want to read about.
Now picture a library shelved by topic. A book about baking bread sits next to a book about sourdough, even though their titles share no words. Walk to the right spot and every book around you is about roughly the same thing.
A vector database is that library for a computer. Each document gets a shelf position based on its meaning. When a question arrives, the database goes to the matching spot and hands back the nearest books.
The shelver gives each piece of content a place on the topic shelves. The aisle signs (the index) lead a new question to the right spot, and the nearest books come back as results.
How it works, step by step
- Your content (the books) can be help articles, product descriptions, contracts or emails. Long documents are usually split into smaller pieces first, like chapters.
- The embedding model (the shelver) reads each piece and turns its meaning into an embedding: a long list of numbers. That list is the book's shelf position.
- The vector database (the topic shelves) stores each embedding, often with a label such as the title, date or department. Microsoft describes a vector database as one designed to store and manage these embeddings.
- The index (the aisle signs) is a shortcut that lets the database jump close to the right shelf instead of checking every book. Common designs have names like HNSW and IVF.
- The search (finding the nearest books) happens when a question arrives. The question is turned into an embedding by the same model, and the database returns the stored items closest to it. Microsoft explains that it works by measuring the distance between the stored vectors and the query.
Try it · Put it in order
Put the library's work in order
Tap the steps in the order they happen.
Where the picture stops
- A real library has shelves in one building you can walk through. Embeddings have hundreds or thousands of numbers, so "nearby" is measured with maths, using rules such as cosine distance or straight-line (L2) distance. The pgvector documentation lists these and others.
- Aisle signs in a library point you to exactly the right shelf. A vector index often does not. pgvector's documentation says searching without an index is exact and finds the true nearest items, while adding an index "trades some recall for speed". Now and then, a close book is missed.
- Being on the same shelf means "about the same topic", not "correct". A vector database finds related content. It does not check whether that content is true or up to date.
Why it matters for your business
- Search that understands customers: people find the right help page or product even when they use different words from the ones on the page.
- Better AI answers: a vector database is the usual way an AI assistant looks up your own documents before answering, a pattern called RAG. Microsoft lists this alongside recommendations as a main use.
- Less to run: you may not need a new product. pgvector adds vector search to PostgreSQL, so vectors can sit with the rest of your data, and Microsoft notes that some databases store embeddings next to the original data rather than in a separate store.
- Control over who sees what: labels such as department or customer let you limit a search, for example to documents a user is allowed to read.
Try it · Side by side
Check every shelf, or follow the aisle signs?
Tap what matters to you (pick one or more) and see which option fits.
Exact search (every shelf)
- Yes. pgvector says exact search gives perfect recall.
- Slows down as the library grows, since every book is checked.
- No index needed.
- Each question checks everything, which gets costly.
Indexed search (aisle signs)
- Usually, but it can miss a close item now and then.
- Built for this: it skips most shelves.
- The index takes time to build and uses extra memory.
- Each question checks only a few shelves.
Pick what matters to you and the better fit lights up.
An example
Imagine a 30-person property management firm with thousands of tenancy letters, repair reports and policy documents. Staff waste time hunting for "that letter about the leaking roof at the corner building". The firm turns each document into an embedding and stores it in a vector database, labelled by building and year. Now a staff member types a question in plain words, picks a building, and gets the closest matching documents at the top. They still open each one to check it is the right letter.
Frequently asked questions
Is a vector database the same as embeddings?
No. Embeddings are the shelf positions, the numbers that describe meaning. The vector database is the library that stores them and finds the nearest ones quickly.
Do I need a special vector database?
Not always. Extensions such as pgvector let PostgreSQL store and search vectors, and some cloud databases include vector search. Dedicated vector databases also exist. The right choice depends on how much data you have and what you already run.
Does a vector database replace keyword search?
Usually not. Keyword search is best for exact words, names and codes. Vector search is best for meaning. Many systems use both together.
Why do results sometimes miss a relevant document?
Fast searches often use an index that checks only the most promising shelves. pgvector's documentation says this can trade some accuracy for speed. Settings let you check more shelves, at the cost of slower answers.
Related explainers
The DevDrift builds AI search and RAG systems that find the right document and show where each answer came from: see how.
Sources
Could you explain this to a colleague now?
Mark it and posts that mention it will show a tick. Saved in this browser only.