CyberFreezeDev Loading
  1. Home
  2. AI glossary
  3. Vector database

What is a vector database?

Storage built to find the items closest in meaning to a query, fast.

3D render of matte white server racks with violet status lights under an overhead cable tray

The plain definition

It stores vectors with IDs and metadata and returns the nearest ones to a query. Options include pgvector inside PostgreSQL, Qdrant, Milvus and Pinecone.

Read more about The plain definition

A vector database stores vectors (lists of numbers) along with an ID and metadata, and supports nearest-neighbour search: give it a query vector and it returns the closest stored vectors.

Common options are pgvector (an extension that adds vector search to PostgreSQL), Qdrant, Milvus, Weaviate, Chroma and the hosted service Pinecone. Some are standalone servers; pgvector lives inside a database you may already run.

How it works

  1. 01 Insert

    Write each embedding with its source reference and metadata such as access group.

    Read more about Insert

    You write each embedding with its source text reference and metadata, such as document name, customer ID, language or access group.

  2. 02 Index

    An approximate nearest neighbour index, often HNSW, avoids checking every vector.

    Read more about Index

    Comparing a query against every vector is slow at scale, so the database builds an approximate nearest neighbour (ANN) index. HNSW, a graph-based index, is the most common.

  3. 03 Query

    The query walks the index and the closest matches return in milliseconds.

    Read more about Query

    The query vector walks the index and the closest candidates come back, usually in milliseconds.

  4. 04 Filter

    Metadata filters narrow results to what this client or user may see.

    Read more about Filter

    Metadata filters (only this client, only documents after a date, only what this user may see) narrow the results before they reach the model.

Where it matters in business

RAG assistants

The retrieval half of RAG is almost always a vector search.

Read more about RAG assistants

The retrieval half of retrieval-augmented generation is almost always a vector search.

Product and content search

Search by meaning across catalogues, help centres and internal wikis.

Read more about Product and content search

Semantic search over catalogues, help centres and internal wikis.

Recommendations

Similar descriptions or images power "customers also viewed" suggestions.

Read more about Recommendations

"Customers who viewed this also viewed" based on similarity of descriptions or images.

A practical example

An agency stores listing embeddings in its existing PostgreSQL with pgvector, so one SQL query filters by price and locality and ranks by meaning.

Read more about A practical example

A real estate agency wants staff to search tens of thousands of listings by description: "3 bedroom near a metro station with covered parking". Listing descriptions are embedded and stored in PostgreSQL with pgvector, next to the existing price, area and locality columns. One SQL query filters by price and locality and ranks the rest by vector similarity. No new database server was needed.

Common mistakes

Adding a new system too early

Below a few million vectors, pgvector in your existing Postgres is often enough.

Read more about Adding a new system too early

Below a few million vectors, pgvector in your existing Postgres is often enough and saves running another service.

Vector search only

Codes, names and numbers match badly on meaning. Add keyword search too.

Read more about Vector search only

Codes, names and numbers match badly on meaning alone. Hybrid search (vector plus keyword, such as BM25) is usually more accurate.

Forgetting deletes

When a document or customer's data is erased, its vectors must go too.

Read more about Forgetting deletes

When a document is removed or a customer asks for erasure under the DPDP Act 2023 or GDPR, its vectors must go too.

Questions

Do I need a separate vector database for RAG?

Not always. PostgreSQL with pgvector, or the vector features in Elasticsearch or OpenSearch, handle many business workloads. A dedicated engine helps at very large scale or with heavy filtering.

Is approximate search accurate enough?

Usually yes. ANN indexes trade a small amount of recall for large speed gains, and the trade-off is tunable. Measure recall on your own queries before and after tuning.

Last updated