Skip to the page
Tecyfy

What is a vector database?

A database built to store embeddings and quickly find the ones closest to a query, which is how AI apps search by meaning.

intermediate · Also called Vector Store

An ordinary database answers exact questions. Which orders came from Leeds? Which customer has this email address? A vector database answers a fuzzier one: which stored items are most like this?

It does that with embeddingsEmbeddingA list of numbers that stands for the meaning of a piece of text, an image or other data. Things with similar meaning get similar numbers, so a computer can find them., lists of numbers that stand for meaning. Every document, product or image you store is turned into one of these lists. When a question comes in, it is turned into a list the same way, and the database returns the stored lists nearest to it. Near in numbers means near in meaning.

Where you meet one

Most AI apps that answer from your own documents use one. In RAGRAGA way to answer from your own documents. A search finds the passages that match the question, and they are added to the prompt before the model writes., documents are cut into chunks, each chunk is embedded and stored, and at question time the vector database hands back the closest chunks for the model to read. The same trick drives "similar products", duplicate detection and search that understands what you meant rather than what you typed.

The hard part is speed

Finding the nearest neighbour is easy with a small collection: compare the question with every one. With millions of lists, each 1,536 numbers long (the size of OpenAI's smaller embedding model), checking them all is too slow.

So vector databases build an index that finds nearly the closest items, very fast. This is approximate nearest neighbour searchApproximate Nearest Neighbor SearchFinding the stored vectors closest to a query without comparing it with every one, by using an index that may now and then miss the true closest in exchange for far faster searches.. The documentation for pgvector, an open-source add-on for Postgres, states the trade-off plainly: an index trades some recall for speed. Now and then the true best match is skipped.

One index type, HNSWHNSWHierarchical Navigable Small World: a vector index that links each vector to its near neighbours in layers of graphs, so a search hops from coarse to fine and checks only a small share of the vectors., builds a layered graph that search can hop through. pgvector notes it gives a better balance of speed and recall than the older IVFFlat index, at the price of slower builds and more memory.

Do you need a separate product?

Not always. Dedicated vector databases exist, but pgvector lets Postgres store vectors right next to your other data. For a modest collection, keeping everything in the database you already run is often simpler.

What it cannot do alone

A vector search finds what is about the same thing, and can miss an exact term such as a product code or an error number. Good search systems run an ordinary keyword search alongside it and merge the results, which is what Anthropic does in its own retrieval setup.

So when an AI app "can't find" something you know is in your files, try the exact phrase. You may be watching the gap between meaning and spelling.

Sources

Where each fact comes from

  1. 1pgvector
  2. 2Introducing Contextual Retrieval
  3. 3Vector embeddings