How does a vector database work? Examples, choosing one, and do you need it for RAG

How vector databases store and search embeddings, examples, choosing one, whether RAG needs one, Supabase vectors, and whether vector databases are dead.

Walking a room through the products he has shipped
Walking a room through the products he has shipped

Key takeaways

  • A vector database stores embeddings with their data and finds the nearest vectors to a query using approximate indexes such as HNSW.
  • Popular options include pgvector, Pinecone, Qdrant, Weaviate, Milvus and Chroma; FAISS is a library rather than a database.
  • RAG needs retrieval, not necessarily a dedicated vector database; pgvector or an in-memory index is often enough.
  • Supabase supports vector search through PostgreSQL's pgvector extension.
  • Vectors have hundreds or thousands of dimensions, not three; vector search is becoming a feature of many databases rather than disappearing.

A vector database stores embeddings, numeric vectors that represent meaning, together with the original data and metadata, and answers queries by finding the vectors closest to a query vector. Approximate nearest-neighbour indexes make this fast even over millions of items. That is the retrieval step behind semantic search and RAG. This page explains how it works and what vector search is, gives examples, helps you choose, answers whether RAG needs one and how to build one, covers Supabase, NoSQL and dimensions, and whether vector databases are dead.

How does a vector database work?

You insert items with an embedding vector, an ID and metadata. The database adds each vector to an index. At query time, you send a query vector, and the database uses the index to return the nearest stored vectors, optionally filtered by metadata.

Also asked as: how does vector database work · examples vector database

Exact search compares the query with every vector, which is slow at scale, so vector databases use approximate indexes. HNSW builds a layered graph where each vector links to near neighbours, and search walks the graph towards the query. Inverted-file indexes cluster vectors and search only the nearest clusters. Product quantisation compresses vectors to save memory. Databases add what libraries lack: persistence, updates and deletes, filtering, access control, replication and scaling.

What is vector search in a database?

Vector search finds items whose embeddings are most similar to a query embedding, measured by cosine similarity, dot product or Euclidean distance. It retrieves by meaning rather than exact words.

Also asked as: what is vector search in database

For example, searching "laptop overheating" can find a help article titled "fan noise and high temperature on notebooks" even with no shared keywords. Many databases now support vector search alongside their normal queries: PostgreSQL with pgvector, OpenSearch and Elasticsearch, MongoDB Atlas and others. Combining vector search with keyword search, called hybrid search, usually gives the best results, because keywords catch exact terms such as product codes that embeddings blur.

What are some examples of vector databases?

Examples include pgvector for PostgreSQL, Pinecone as a managed service, Qdrant, Weaviate and Milvus as open-source dedicated vector databases, Chroma for lightweight local use, and vector search features in OpenSearch, Elasticsearch and MongoDB Atlas.

Related tools that are not full databases: FAISS, a library for fast similarity search in memory, and hnswlib, an index library. Cloud providers also offer vector capabilities in their managed databases and storage services. The landscape changes quickly, but the core ideas, embeddings, approximate indexes, filtering and hybrid search, stay the same across products.

Which vector database should I choose?

Choose the simplest option that meets your needs: pgvector if you already use PostgreSQL, Chroma or FAISS for prototypes, Qdrant, Weaviate or Milvus for a dedicated open-source service, and Pinecone if you want fully managed scaling.

Also asked as: which vector database to choose

Questions to decide:

  • How many vectors now and in a year: thousands, millions or billions?
  • Do you need metadata filters, multi-tenancy or access control?
  • Do you need keyword plus vector search?
  • Who will operate it: your team or a vendor?
  • Where must data live for privacy or compliance?

For most student and startup projects, pgvector on a hosted PostgreSQL is enough. Measure retrieval recall on your own questions before switching for performance reasons.

Does RAG need a vector database?

RAG needs retrieval, not necessarily a dedicated vector database. For small document sets, an in-memory index such as FAISS, or pgvector in your existing database, is enough; some systems even use keyword search alone.

Also asked as: does rag need vector database

What RAG really needs is good retrieval: clean chunks, a suitable embedding model, hybrid keyword plus vector search, reranking and evaluation. RAG.NextUpgrad runs hybrid dense and BM25 retrieval with reciprocal-rank fusion and re-ranking in about 220 MB on a free tier, which shows that heavy infrastructure is not required. Move to a dedicated vector database when scale, filtering, concurrency or operations demand it.

How do I create a vector database for RAG?

Chunk your documents, embed each chunk with one embedding model, store chunks with their vectors and metadata in a vector store, then retrieve with the same model at query time. With PostgreSQL and pgvector, it is a table with a vector column and an index.

Also asked as: how to create vector database for rag

create extension if not exists vector;
create table chunks (id bigserial primary key, doc text, page int, content text, embedding vector(768));
create index on chunks using hnsw (embedding vector_cosine_ops);
-- query: nearest 5 chunks to a query embedding
select doc, page, content from chunks order by embedding <=> $1 limit 5;

Match the vector dimension to your model, add a full-text index for keyword search, and store page numbers for citations.

Does Supabase have a vector database?

Yes. Supabase supports vector storage and search through pgvector, a PostgreSQL extension, so you can store embeddings next to your other data and query them with SQL or through Supabase's client libraries.

Also asked as: does supabase have vector database

Enable the extension, create a table with a vector column, add an index, and write a database function for similarity search that your app calls. Supabase's AI documentation includes guides for semantic search and RAG. Because it is PostgreSQL, you also get row-level security for access control, joins with user data and transactions, which dedicated vector databases may not offer. For student projects, Supabase's free tier is a convenient way to build a full RAG backend.

Is a vector database NoSQL?

Usually it is described as a NoSQL-style system, because dedicated vector databases do not use relational tables and SQL as their main model. But vector search also exists inside SQL databases, such as PostgreSQL with pgvector.

Also asked as: is vector database nosql

Dedicated vector databases expose APIs for collections of points or objects with vectors and metadata, closer to document stores. SQL databases with vector extensions let you mix vector similarity with joins, filters and transactions. The classification matters less than the features you need: query language, filtering, consistency, scale and operations. Many teams prefer keeping vectors in the same database as their application data to avoid syncing two systems.

Is a vector database 3D?

No. Vectors in a vector database usually have hundreds or thousands of dimensions, such as 384, 768 or 1536, not three. Each dimension is a learned feature of meaning, not a spatial direction.

Also asked as: is vector database 3d

Three-dimensional pictures of embeddings in tutorials are simplifications made with dimension-reduction methods such as PCA, t-SNE or UMAP, which squash high-dimensional vectors into two or three dimensions for visualisation. They help intuition, showing that similar items cluster, but distances in the picture are distorted. Search always happens in the full high-dimensional space.

Is the vector database dead?

No, but it is changing. Vector search is becoming a standard feature of general-purpose databases and storage services, long context windows reduce the need for retrieval in some cases, and agentic search with keywords works for some tasks. Dedicated vector databases still matter at large scale and for specialised needs.

Also asked as: is vector database dead

The durable part is retrieval itself: most AI applications still need to find the right information quickly, cite it and control access. Whether that runs in a dedicated vector database, PostgreSQL with pgvector, a search engine or a library depends on scale and team. Focus on retrieval quality and evaluation, and keep your design portable, so the storage choice can change as the market does.

Sources

  1. Malkov & Yashunin, Efficient and robust approximate nearest neighbor search using HNSW graphs (2016)arxiv.org
  2. pgvector, repositorygithub.com
  3. Supabase, AI and vectors documentationsupabase.com
  4. Qdrant, documentationqdrant.tech
  5. Lewis et al., Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks (2020)arxiv.org
Pranjul Rathour
Pranjul Rathour
GenAI Engineer · India

GenAI engineer and AI product builder with 2+ years shipping production-grade AI systems: RAG pipelines, fine-tuned LLMs, hybrid retrieval and multi-modal apps across vision, speech and OCR, architected end to end from ingestion to deployment. Leads engineering for SCULT INDIA's 14-member team, founded the 500+ member TechVerse Enclave community and has mentored 200+ students. Three hackathon first prizes: Changethon 2025 (IIT Roorkee), Product Genesis at Vividhotsava 2025 (CSJMU) and BYTEBATTLE (MeetKats).

Open to GenAI roles, hackathon judging, mentorship sessions and guest talks at colleges. For campus sessions the inviting institution covers the visit end to end: travel (a First AC train ticket for journeys up to five hours, a flight for anything longer), accommodation, meals, and pickup and drop; the honorarium and workshop fees are negotiable on WhatsApp or on the call, and requests are welcome from institutions that can cover the visit this way. Email pranjulrathour41@gmail.com.

Keep reading

More on RAG & retrieval

All RAG & retrieval guides →
Campus talks · hackathon judging · mentoring

Want this as a live session at your college?

Open to GenAI roles, hackathon judging, mentorship sessions and guest talks at colleges. For campus sessions the inviting institution covers the visit end to end: travel (a First AC train ticket for journeys up to five hours, a flight for anything longer), accommodation, meals, and pickup and drop; the honorarium and workshop fees are negotiable on WhatsApp or on the call, and requests are welcome from institutions that can cover the visit this way.

Pranjul Rathour, GenAI engineer in India