recallA retrieval
field guide

Why Vector Databases Exist

Build this skill

Explain why similarity search needs special indexes and what a vector database adds over a matrix or library.

A list of numbers is not a database

Suppose every passage in the Kaveri Institute handbook has been embedded and the embeddings sit in a NumPy array. To answer a question, you embed it, compare it with every row, and keep the closest few. For a few thousand passages this works well.

Now run the college helpdesk on it for a year. New circulars must be added every week and withdrawn notices removed at once. The array lives only in memory, so a server restart wipes it. Eight thousand students search at the same time, staff-only documents must stay hidden from students, and the collection grows into the millions. Programming all of that by hand means writing your own database.

A vector database is a system built to do exactly this. It stores embeddings together with their text and metadata (facts about each passage, such as its department, date and who may read it), and it answers one question very quickly: which stored vectors are closest to this query vector? It combines fast similarity search with the reliability of a database: saving to disk, updates, deletes, backups and many users at once.

Why the databases you know struggle with "closest"

Relational databases such as PostgreSQL and MySQL are excellent at exact questions: "find the student with roll number 22B81A0512", "list all circulars from October". They answer these with indexes, structures such as sorted lists and trees that let the database jump straight to the matching rows instead of reading every row.

A library works the same way. With a book's call number, the catalogue sends you to one shelf, however large the library is. Ask for "books that feel like this one" and the catalogue cannot help, because nothing is sorted by "feels like".

Similarity search is that second kind of question. There is no exact value to look up, and closeness depends on all 1,024 numbers of an embedding together, so a sorted index on one column does not help. Without a special kind of index, the database must compare the query with every row. This is brute-force search, and its cost grows in step with the data: ten times the passages means ten times the work for every question.

Ordinary database query“roll_no = 22B81A0512”Exact matchB-tree index jumps to the rowMilliseconds at any sizeSimilarity query“closest to this embedding”No exact match existsNeeds a vector indexBrute force grows with data

Ordinary indexes answer “equals” and “between” questions. Similarity search needs a different kind of index.

Watching brute force slow down

The program below runs a brute-force search over 1,000, then 10,000, then 100,000 fake embeddings and times each one. Run it and compare the last column from row to row.

python · runs in your browser

Example output (your timings will differ):

text
  1,000 passages:   1,000 comparisons,   0.65 ms
 10,000 passages:  10,000 comparisons,   1.50 ms
100,000 passages: 100,000 comparisons,  13.21 ms

passages @ query is the whole brute-force search: it multiplies every row with the query and adds up the result, giving one similarity score per passage. np.argsort(-scores)[:3] then sorts the scores from highest to lowest and keeps the positions of the top 3. The two perf_counter() calls read a clock before and after, so their difference is the search time.

The time climbs with the number of passages. A few hundredths of a second for one question sounds acceptable, but a busy system answers many questions every second, and real collections are far larger than 100,000 passages. Try the numbers for yourself.

What a vector database adds

A vector database avoids most of that work with a vector index, a structure built ahead of time that lets a search look only where the nearest vectors are likely to be. Around that index, most vector databases provide the same set of features:

Feature Why it matters
Vector indexes (such as HNSW and IVF) Find the nearest vectors without checking every one
Metadata stored with each vector Filters, citations, permissions
Insert, update and delete Keep the collection up to date as documents change
Persistence and backups Survive restarts and failures
Many users at once Serve a whole college or company
Choice of distance measure Cosine, dot product or Euclidean

The lab below puts the same student question to an ordinary SQL keyword query and to a vector search over the same table.

Three ways to get these features

The tools come in three kinds, and they differ in how much of the database work they do for you. A vector search library, such as FAISS, gives you fast indexes inside your own program and leaves storage, updates and serving to you. A vector extension for an existing database, such as pgvector for PostgreSQL, adds vector columns and indexes to a database the team already runs. A purpose-built vector database, such as Qdrant, Milvus, Weaviate or Pinecone, is designed around vector search from the start.

LibraryFAISSFast indexes in your programYou handle storage and usersDatabase extensionpgvector for PostgreSQLVectors next to your tablesOne system to runPurpose-built databaseQdrant, Milvus, Weaviate, PineconeDesigned around vector searchBuilt for large scale

From left to right, the tool does more of the database work for you.

A pilot with a few thousand passages needs none of them; a NumPy array is fast and simple at that size. Many teams start there, prove the idea works, and move to a database when updates, filters, many users or scale arrive.

Follow your curiosity.

↑ ↓ to explore · Enter to open · Escape to close