Level 2: Builder Concepts

Vector Databases Explained for Beginners: How AI Searches by Meaning

Satvik ParamkushamUpdated October 5, 202616 min read

Quick answer

A vector database is a database built to store embeddings (lists of numbers that capture meaning) and quickly find the ones most similar to a query. Instead of matching exact words or values like a SQL database, it searches by meaning, which makes it a core building block for semantic search, recommendations and RAG chatbots.

In Hindi: Vector database ek aisa database hai jo data ko uske matlab ke hisaab se store karta hai, aur exact shabd nahi, balki milte-julte matlab wale results dhoondh kar deta hai.

Table of Contents

Search for "running shoes" in a normal database, and it looks for rows that contain those exact words. A listing titled "lightweight jogging sneakers" never shows up, even though it is exactly what you wanted. Traditional databases are excellent at exact matches and terrible at "things like this".

A vector database fixes that. It stores data as embeddings, which are numerical fingerprints of meaning, and answers one question extremely well: "which stored items are closest in meaning to this one?" That single ability sits underneath semantic search, product recommendations and most RAG chatbots you see today.

When I explain vector databases to students, I start with a library. A normal library shelves books by title or accession number. Now imagine a library that shelves books by what they are about, so every book on cricket strategy sits together no matter what its title says. That is the heart of a vector database. By the end of this page you will know how one works, how it differs from SQL, which popular names to know, and when you can skip one entirely.

What is a vector database in simple terms?

In simple terms, a vector database is a storage system that keeps data as lists of numbers representing meaning, and finds the items most similar to whatever you search for.

Go back to the library-by-meaning idea. In this library:

  • Every book has a location based on its topic, not its title. Books on Indian history cluster together, and books on machine learning sit in another corner.
  • When you walk in with a question, the librarian works out where your question would sit on the shelves.
  • The librarian then hands you the books nearest to that spot, even if none of them use the exact words in your question.

In a vector database, the "locations" are embeddings, lists of hundreds or thousands of numbers produced by an embedding model. The "librarian" is a search algorithm that finds the closest vectors very quickly, even among millions.

Along with each vector, the database usually stores the original content (a paragraph, a product title, an image link) and metadata such as the date, category or price. That lets you search by meaning and filter by facts at the same time.

What is a vector database in AI and why is it used?

In AI, a vector database is the memory layer that lets applications store embeddings and retrieve relevant information by meaning, which is why it shows up in so many LLM apps.

AI systems increasingly turn everything into embeddings: documents, questions, images, user profiles and products. Once you have millions of those vectors, you need somewhere to keep them and a fast way to search them. A spreadsheet or a regular table can store the numbers, but it was not designed to answer "find the 5 closest vectors out of 10 million" in a few milliseconds.

The main reasons AI teams use vector databases:

  1. Semantic search. Find documents by meaning, so "salary credited late" matches a help article titled "Payroll delays".
  2. RAG chatbots. Give a large language model the right passages from your documents before it answers.
  3. Recommendations. Suggest videos, courses or products similar to what a user liked.
  4. Agent memory. Let an AI agent store notes from earlier conversations and recall the relevant ones later.
  5. Duplicate and fraud detection. Spot near-identical complaints, listings or images that are worded differently.
  6. Image and multimodal search. Search a photo collection by typing a description.

The common thread is simple: whenever an app needs "find similar" at scale, a vector database is a strong candidate.

How does a vector database work?

A vector database works by turning data into embeddings, organising those embeddings in a special index, and then searching that index for the vectors nearest to a query.

Here is the full flow, from raw data to search result:

  1. Prepare the data. Split long content into chunks, such as product descriptions or a few paragraphs of a PDF.
  2. Create embeddings. Run each chunk through an embedding model to get a vector. Some vector databases can call the model for you; others expect you to send ready-made vectors.
  3. Insert. Store each vector with an ID, the original text and metadata like category, date or language.
  4. Index. The database builds an index, a smart data structure that groups or links vectors so it does not have to compare every single one during a search.
  5. Query. A user's search text is embedded with the same model used for the data.
  6. Search. The database uses the index to find the vectors closest to the query vector, usually measured with cosine similarity or distance.
  7. Filter and return. It applies any metadata filters (for example, "only documents from 2026") and returns the top results with their text and scores.

Steps 1 to 4 happen when data is added or updated. Steps 5 to 7 happen on every search, often in a fraction of a second.

The index in step 4 is the clever part, and it deserves its own explanation.

How similarity search works: nearest neighbours, explained

Similarity search works by finding the nearest neighbours of a query vector, meaning the stored vectors that sit closest to it in the space of meaning.

Exact search: check everyone

The simplest method compares the query with every stored vector and keeps the closest ones. People call this exact or brute-force k-nearest-neighbour search, where k is the number of results you want. It always finds the true closest matches. It is also slow when you have millions of vectors, because the work grows with the size of the data.

Approximate search: check the likely neighbourhood

Most vector databases use approximate nearest neighbour (ANN) search instead. The idea is to skip most of the data and only check vectors in the most promising area. You give up a tiny bit of accuracy and gain a large jump in speed.

Two popular ANN approaches, at a high level:

  • Graph-based (HNSW). Hierarchical Navigable Small World graphs link each vector to its neighbours in several layers. A search starts on a sparse top layer, like taking a national highway to the right state, then moves down to denser layers, like district roads and then local lanes, until it reaches the closest points. HNSW was described in a paper by Yury Malkov and Dmitry Yashunin and is widely used.
  • Cluster-based (IVF). Vectors are grouped into clusters ahead of time, a bit like sorting addresses by PIN code. At search time, the database checks only the few clusters nearest to the query instead of the whole country.

Most databases let you tune this trade-off. Settings that check more of the neighbourhood give better recall (finding more of the true best matches) but take longer.

Vector database example: an online store's product search

A clear vector database example is an online clothing store that lets shoppers search by description and get relevant products even when the words do not match.

Imagine a small ethnic-wear brand in Jaipur with 20,000 products. Each product has a title, a description, a price and a category. The team does the following:

  1. Combines title and description for each product and creates an embedding.
  2. Stores each embedding in a vector database with metadata: price, category, size range and stock status.
  3. Embeds every shopper's search text with the same model at search time.

A shopper types: "light cotton kurta for summer office wear under 1000 rupees".

  • The vector search finds products whose meaning is close: breathable cotton kurtas, short kurtis described as "ideal for hot weather", and simple straight-cut designs tagged as workwear.
  • A metadata filter removes anything above 1,000 rupees and anything out of stock.
  • The shopper sees relevant results, including items that never used the word "office" or "summer" in their titles.

A plain keyword search would have matched "cotton" and "kurta" and missed the intent behind "summer office wear". That gap, between the words people type and the meaning they intend, is exactly what vector databases close.

The same pattern shows up in job portals matching resumes to job descriptions, edtech apps suggesting the next lesson, and news apps grouping similar stories together.

Vector database in RAG: where it fits

In RAG, the vector database is the retrieval engine: it stores your document chunks as embeddings and returns the most relevant ones for each question.

A RAG system answers questions using your own documents. Its pipeline looks like this, and the vector database handles the store and retrieve steps:

  1. Chunk your documents into small passages.
  2. Embed each passage.
  3. Store the embeddings and passages in a vector database. (Vector database)
  4. Retrieve the passages closest to the user's question. (Vector database)
  5. Augment the prompt with those passages.
  6. Generate the answer with an LLM.

Take a college rulebook chatbot. A student asks, "What happens if I miss an internal exam due to illness?" The vector database finds the rulebook passages about medical absence and re-tests, even though the rulebook might say "make-up assessment" rather than "re-exam". The LLM then writes an answer from those passages.

Metadata filters matter a lot in RAG. If the rulebook has a 2025 and a 2026 version, filtering by year stops the bot quoting the old rule. If an HR bot serves several offices, filtering by location stops a Pune employee getting Hyderabad's holiday list.

If you are deciding between adding knowledge through RAG or retraining a model, our RAG vs fine-tuning guide covers that choice.

Vector database vs SQL database: what is the difference?

A SQL database finds rows that exactly match conditions you write, while a vector database finds items whose meaning is closest to a query.

Traditional SQL databaseVector database
StoresRows and columns (names, prices, dates)Vectors (embeddings) plus content and metadata
Query styleExact conditions, like price below 1000 and city equals PuneSimilarity, like "find items most like this text"
ResultEvery row that matches, or noneThe top k closest items, ranked by similarity score
Handles synonyms and paraphrases?No, unless you add special search featuresYes, through embeddings
Best atTransactions, accounts, inventory, reportsSemantic search, recommendations, RAG
Typical examplesMySQL, PostgreSQL, OraclePinecone, Milvus, Qdrant, Weaviate, Chroma

The two are partners, not rivals. A typical app keeps orders, users and payments in a SQL database, because you never want an "approximately correct" bank balance. It then uses vector search for the parts that need meaning, like search and recommendations.

The line is also blurring. PostgreSQL can do vector search through the open-source pgvector extension, and several general-purpose databases and search engines have added vector search features. Check current documentation for exact capabilities, since this area changes quickly.

The vector database names you will hear most often are Pinecone, Weaviate, Milvus, Qdrant, Chroma and pgvector for PostgreSQL.

NameWhat it isOften chosen when
PineconeA fully managed cloud vector database serviceYou want a hosted service and do not want to run servers
WeaviateAn open-source vector database, also offered as a managed cloudYou want open source with a hosted option
MilvusAn open-source vector database designed for large-scale deploymentsYou expect very large collections and can run your own infrastructure
QdrantAn open-source vector database written in Rust, with a cloud optionYou want open source with filtering features and a hosted option
ChromaAn open-source embedding database popular with Python developersYou are prototyping or learning and want a quick local setup
pgvectorAn open-source extension that adds vector search to PostgreSQLYou already use Postgres and want vectors next to your normal data

You will also come across FAISS, a library from Meta's AI research team for fast similarity search. FAISS is a library you build into your own code, not a full database with storage, users and an API, but many tools use it under the hood.

I am deliberately not ranking these. Features, pricing and limits change often, and the right choice depends on your data size, budget, team skills and where your app runs. Read each project's current documentation and try two of them on your own data before deciding.

When do you not need a vector database?

You do not need a vector database when your data is small enough to search directly in memory, or when your problem is really about exact matches.

Here is my contrarian take: many beginner projects add a vector database because tutorials do, not because the project needs one. If you have a few hundred or a few thousand chunks, a simple list of embeddings in memory works fine. You compare the query vector with every stored vector, sort by similarity and take the top five. On a modern laptop that is fast enough for a student project or an internal tool used by a small team.

You can usually skip a dedicated vector database when:

  • Your data is small. A single syllabus, one company handbook or a few hundred FAQs.
  • Your data fits in the prompt. If the whole document fits comfortably in the model's context window, you may not need retrieval at all.
  • You need exact lookups. Roll numbers, order IDs and PIN codes belong in a normal database or a keyword index.
  • You already run Postgres. Adding pgvector can be simpler than running another system.

You probably do need one when you have hundreds of thousands of vectors or more, frequent updates, many users searching at once, or heavy metadata filtering.

How to start learning vector databases as a beginner

The best way to learn vector databases is to build one tiny semantic search project, first without a database and then with one.

A path that works well:

  1. Understand embeddings first. Make sure you are comfortable with what embeddings are and how cosine similarity works.
  2. Build it in memory. Embed 100 short texts, such as FAQs from your college website, store the vectors in a Python list and write your own "find top 5" function. This shows you exactly what a vector database automates.
  3. Move to a local vector database. Load the same data into a beginner-friendly option like Chroma, or into Postgres with pgvector, and compare the code.
  4. Add metadata filters. Tag each FAQ with a department and search within one department only.
  5. Plug it into an LLM. Pass the top results to a model and you have built a basic RAG system.

I think step 2 is the one most people skip, and it is the one that makes everything else click. Once you have written nearest-neighbour search by hand, every vector database feels like a faster version of something you already understand.

Vector databases come up regularly in interviews for AI engineering and data roles, usually alongside RAG and embeddings. Our AI interview prep section has practice questions on all three.

Key takeaways

  • A vector database stores embeddings and finds the items most similar in meaning to a query.
  • It works like a library shelved by topic: your question is placed on the shelf, and the nearest books come back.
  • Most vector databases use approximate nearest neighbour search (like HNSW) to trade a little accuracy for a lot of speed.
  • SQL databases handle exact matches and transactions; vector databases handle similarity, and many apps use both.
  • Popular names include Pinecone, Weaviate, Milvus, Qdrant, Chroma and pgvector for PostgreSQL.
  • For small datasets, a simple in-memory list of embeddings is often enough.

Try it yourself

Paste these into ChatGPT, Claude or Gemini to learn Vector Database by doing.

Explain vector databases simply

Explain what a vector database is to a college student in India with no database background. Use the analogy of a library that shelves books by meaning, then explain nearest neighbour search in under 150 words.

Choose between SQL and vector search

I am building an app for my college with student records, fee payments and a searchable FAQ. Tell me which parts should use a SQL database, which parts need vector search, and why, in a simple table.

Build a tiny semantic search

Guide me step by step to build a tiny semantic search in Python over 100 FAQs: first with an in-memory list of embeddings and cosine similarity, then with a beginner-friendly vector database. Explain each step before giving code.

Quick quiz: test yourself on Vector Database

1. What does a vector database mainly search by?

  1. Exact keywords only
  2. Similarity in meaning between embeddings
  3. File size
  4. Alphabetical order
Show answer

B. Similarity in meaning between embeddings. A vector database compares embeddings and returns the stored items whose meaning is closest to the query.

2. Why do most vector databases use approximate nearest neighbour (ANN) search?

  1. It is the only way to store numbers
  2. It guarantees perfect accuracy
  3. It is much faster on large data, at the cost of a little accuracy
  4. It removes the need for embeddings
Show answer

C. It is much faster on large data, at the cost of a little accuracy. ANN search checks only the most promising part of the data, which makes searches over millions of vectors fast while staying highly accurate.

3. Which task is better suited to a traditional SQL database than a vector database?

  1. Finding FAQs similar to a user's question
  2. Recommending similar products
  3. Storing and updating a customer's account balance
  4. Retrieving passages for a RAG chatbot
Show answer

C. Storing and updating a customer's account balance. Account balances need exact, reliable transactions, which is what SQL databases are built for. The other tasks need similarity search.

Frequently asked questions

What is a vector database in simple words?

A vector database is a database that stores data as embeddings, which are lists of numbers capturing meaning. When you search, it returns the items closest in meaning to your query, not just exact keyword matches. It works like a library where books are shelved by topic instead of title.

Why is a vector database used in AI?

AI apps turn text, images and other data into embeddings and need a fast way to find similar ones. A vector database stores millions of embeddings and finds the closest matches in milliseconds. That powers semantic search, recommendations, agent memory and RAG chatbots.

What is the role of a vector database in RAG?

In RAG, the vector database stores document chunks as embeddings and retrieves the chunks most relevant to each question. Those chunks are then added to the LLM's prompt so it can answer from your documents. Metadata filters help it skip outdated or irrelevant documents.

What are some examples of vector databases?

Common names include Pinecone, Weaviate, Milvus, Qdrant and Chroma, plus pgvector, which adds vector search to PostgreSQL. FAISS from Meta is a popular similarity search library that many tools use internally. Features and pricing change often, so check each one's current documentation.

Is a vector database better than a SQL database?

Neither is better overall; they solve different problems. SQL databases are best for exact matches and transactions like orders and payments. Vector databases are best for finding similar items by meaning, and many real apps use both together.

Can I use PostgreSQL as a vector database?

Yes, with the open-source pgvector extension, PostgreSQL can store embeddings and run similarity searches. It is a popular choice for teams that already use Postgres and want vectors next to their regular data. Very large or specialised workloads may still suit a dedicated vector database.

Do I always need a vector database for embeddings?

No. For a few thousand embeddings, you can store them in memory and compare them directly with a simple loop. A vector database becomes worth it when you have large data, frequent updates, many users or complex filters.

References