Skip to main content
AIDevOps
  • Learn
  • Learning Paths
  • Practice
  • Open Source
  • Books
  • Engineering

    AI DevOpsThe full map of building and operating AI servicesLLMOpsLLM deployment Β· evaluation Β· observabilityHands-on ProjectsBuild AI Agent projects

    Knowledge

    DocsTechnical documentationBlogEngineering articlesPloggerDevelopment log feed

    Validate

    Certification3-level skills certification Β· coming soon
AI Models
LlamaTutorial|MistralTutorial|GemmaTutorial|DeepSeekTutorial|QwenTutorial
πŸ’Ύ Database
DB Intro & RoadmapCore SQLOracleMySQLPostgreSQL|MongoDBVector DB
πŸ€– AI Applied Development
Applied AI Intro & RoadmapHugging FaceLangChainLlamaIndexLLMOps|LangGraphMCPMulti-AgentAgent Evaluation
🧠 AI Core
AI Intro & RoadmapML FundamentalsLLM Fundamentals|Python AIC++|PyTorchTensorFlowJAX
🧠 AI Agent Development
Finance AI AgentLLM API ServerStock Investing AgentAIOps AI AgentEducation AI AgentCoding AI Agent
🌱 Spring Cloud
Spring Intro & RoadmapSpring Cloud GatewaySpring BootJava|Spring AISpring SecuritySpring BatchSpring JPA
🐳 DevOps
DevOps Intro & RoadmapLinuxDockerCI/CD|Kubernetes BasicsK8s AdvancedPrometheusGrafana
🧱 Infrastructure
Infrastructure Intro & RoadmapNginxRedis
☁️ Cloud
Cloud Intro & RoadmapAWSGCPAzureNCPCloudflare
🎨 Frontend
Frontend Intro & RoadmapJavaScriptTypeScript|ReactNext.js|VueNuxt|Electron
πŸ“± Mobile
Mobile Intro & RoadmapKotlinAndroidFlutter
βš™οΈ Backend
Backend Intro & RoadmapPython BasicsFastAPIDjangoFlask|CGoGinNode.js
πŸ§ͺ Testing
k6JMeternGrinder
AIDevOps

Engineering AI. From Code to Production.
An engineering learning platform for building and operating AI and AI Agents

Learn

  • All Guides
  • Learning Paths
  • AI Tutorial
  • Practice
  • Books

Resources

  • AI DevOps
  • LLMOps
  • Hands-on Projects
  • Docs
  • Blog
  • Plogger
  • Open Source
  • Certification (coming soon)

Start Here

  • AI Core Roadmap
  • AI Applied Development Roadmap
  • Spring Cloud Roadmap
  • DevOps Roadmap
  • Infrastructure Roadmap

Β 

  • Cloud Roadmap
  • Frontend Roadmap
  • Mobile Roadmap
  • Backend Roadmap
  • Database Roadmap
Β© 2026 AIDevOps. All rights reserved.
Terms of ServicePrivacy PolicySitemaptestforge.kr
  1. Home
  2. Learn
  3. Database
  4. Vector DB
Guide to vector databases for AI RAG and similarity search

🧠 Vector DB Complete Guide

Visitors

Learn the high-dimensional vector databases used to implement the RAG (retrieval-augmented generation) architecture at the heart of LLM (large language model) applications. Covers the kinds of distance metric, a comparison of the leading vector DB products, index theory for fast similarity search, and practical Python integration code.

  • Advanced
  • Updated Oct 1, 2026
  • ~5 min read
  • 9 sections
  • 2 code examples

Learning Paths that include this guide

This guide is one step in the paths below. Study it together with the steps before and after.

  • AI Agent Engineer β†’
  • AI Application Engineer β†’
  • AI Platform Engineer β†’
Implementing AI RAG (retrieval-augmented generation)Text/image similarity searchAI Agent memory managementBuilding recommendation engines

Related frameworks & environments

🐍Python AIβ†’LCLangChainβ†’LILlamaIndexβ†’πŸ˜PostgreSQLβ†’

Contents

0 / 12
  1. How to use this guide
  2. Architecture diagrams
  3. Vector search & RAG concepts
  4. Distance metrics for measuring similarity
  5. Comparing the main vector DB solutions
  6. Vector indexes (HNSW vs IVF-FLAT)
  7. Working with a vector DB in Python
  8. Vector DB access control & API key security
  9. Vector DB design
  10. Operating standards
  11. Verification strategy
  12. Frequently asked questions
Contents 12 sections
  1. How to use this guide
  2. Architecture diagrams
  3. Vector search & RAG concepts
  4. Distance metrics for measuring similarity
  5. Comparing the main vector DB solutions
  6. Vector indexes (HNSW vs IVF-FLAT)
  7. Working with a vector DB in Python
  8. Vector DB access control & API key security
  9. Vector DB design
  10. Operating standards
  11. Verification strategy
  12. Frequently asked questions

How to use this guide

How to read it

Understanding Vector DB as a real-world workflow

Learn the high-dimensional vector databases used to implement the RAG (retrieval-augmented generation) architecture at the heart of LLM (large language model) applications. Covers the kinds of distance metric, a comparison of the leading vector DB products, index theory for fast similarity search, and practical Python integration code. Rather than listing concepts, this guide is organized so you can follow the content in the order you have to make decisions on a real project.

Key perspective

AI / LLM systems

Look beyond the model and the prompt: connect the data flow, evaluation, and post-deployment operating metrics in one view.

Implementing AI RAG (retrieval-augmented generation)Text/image similarity searchAI Agent memory managementBuilding recommendation engines

Architecture diagrams

To make what you read stick, it helps to capture the flow as a picture first. The two diagrams below are reference maps you can keep coming back to while learning Vector DB.

Learning flow

Rendering diagram…

Architecture view

Rendering diagram…

Vector search & RAG concepts

When you first open Vector DB, the big picture matters more than individual commands. This section starts with the problems the concepts ahead were created to solve.

A vector database stores embedding data in a high-dimensional mathematical vector space (typically 768 or 1536 dimensions) and finds the embeddings closest to the query vector at very high speed through similarity search. It serves as the backbone of RAG systems, which inject recent/private document information the LLM was not trained on.
Rendering diagram…

Distance metrics for measuring similarity

Distance metrics for measuring similarity is a point where the options diverge. Using the table to compare what each approach is for and how it differs in operation makes later decisions much easier.

These are the kinds of mathematical metric that judge similarity by measuring the distance between vectors. The metric the embedding model supports (for example OpenAI text-embedding-3) and the metric of the vector DB index must match to guarantee accurate search results.
MetricMathematical definitionSuitable workloads
Cosine SimilarityComputes similarity from the angle between two vectors (direction-centered)Widely used for semantic text search and document RAG
L2 Distance (Euclidean distance)Measures the straight-line distance between two vector points (smaller means more similar)Image search, when absolute magnitude matters
Dot ProductConsiders the length and angle of two vectors together (same as cosine for normalized vectors)Very fast; suits search over normalized embeddings

Comparing the main vector DB solutions

Comparing the main vector DB solutions is a point where the options diverge. Using the table to compare what each approach is for and how it differs in operation makes later decisions much easier.

From standalone serverless vector DBs to extensions of an existing RDBMS, choose the solution that fits your requirements and scale.
SolutionTypeStrengthsLimits
PineconeSaaS (Managed)The convenience of serverless operation with nothing to install; excellent indexing speedCost of an external cloud service; no offline support
ChromaDBEmbedded / localComes as a Python library, making local development and validation very simplePerformance limits under heavy traffic and concurrent production workloads
MilvusStandalone distributed serverLarge enterprise-grade workloads; the distributed architecture overcomes volume limitsHigh overhead of building and operating distributed infrastructure such as Kubernetes
pgvectorPostgreSQL extensionFull relational joins inside your existing PostgreSQL databaseShares memory with the RDB, so memory pressure when loading very large volumes of vectors

Vector indexes (HNSW vs IVF-FLAT)

Vector indexes (HNSW vs IVF-FLAT) is a point where the options diverge. Using the table to compare what each approach is for and how it differs in operation makes later decisions much easier.

To find similar vectors among tens of millions at high speed (milliseconds), you have to design and use an approximate nearest neighbor (ANN) algorithm index, which sacrifices a little accuracy in exchange.
Index typeHow it worksPros and cons
HNSW (Hierarchical Navigable Small World)Connects the vectors in a multi-layer graph structure and searches hierarchicallyThe fastest query response time available today, with high search accuracy / extremely heavy memory use for index builds
IVF (Inverted File Index)Partitions the whole vector space into clusters and searches the list a query belongs toLow index build time and memory use / somewhat lower accuracy and query throughput (QPS) than HNSW

Working with a vector DB in Python

Here you look at Working with a vector DB in Python alongside real code. Rather than copying the example as-is, read it with an eye on the inputs, the outputs, and the parts most likely to change.

Practical Python code that uses ChromaDB, the most widely used local vector DB library, to create a collection and store and search text embeddings.
chroma_demo.pyPYTHON
import chromadb

# 1. Initialize the local Chroma client
client = chromadb.PersistentClient(path="./chroma_db")

# 2. Create a collection (a default embedding model is provided)
collection = client.get_or_create_collection(name="ai_devops_docs")

# 3. Load documents and metadata
collection.add(
    documents=[
        "FastAPI is a very fast web framework based on Python.",
        "Docker is a tool for deploying applications in containers.",
        "A vector DB is a store specialized in searching high-dimensional AI embeddings."
    ],
    metadatas=[
        {"category": "backend"},
        {"category": "ops"},
        {"category": "database"}
    ],
    ids=["doc1", "doc2", "doc3"]
)

# 4. Run a similarity search
results = collection.query(
    query_texts=["What is a tool for deploying containers?"],
    n_results=1
)

print("Search result:", results["documents"][0][0])
# Output: Docker is a tool for deploying applications in containers.

Vector DB access control & API key security

Here you look at Vector DB access control & API key security alongside real code. Rather than copying the example as-is, read it with an eye on the inputs, the outputs, and the parts most likely to change.

For a large vector DB, whether a cloud-based SaaS (for example Pinecone) or a standalone distributed server (for example Milvus), authentication and fine-grained role control (RBAC) are essential. The rules for preventing API key exposure and delegating permissions must be followed strictly.
vector_auth.pyPYTHON
# 1. Example Milvus (PyMilvus) enterprise RBAC setup
from pymilvus import connections, utility, Role

connections.connect("default", host="localhost", port="19530")

# Create a user and a custom role
utility.create_user(user="rag_app_user", password="securePassword123")
role = Role("rag_search_role")
role.create()

# Map read-only privileges on a specific collection to the role
# Various scopes can be specified: Global, Collection, and so on
role.grant(object_type="Collection", object_name="ai_docs", privilege="Search")
role.grant(object_type="Collection", object_name="ai_docs", privilege="Query")

# Bind the role to the user
role.add_user("rag_app_user")

# 2. Pinecone API Key Scopes (SaaS Access Control)
# Pinecone can control permissions (scopes) per API key.
# - Read-Only: allows query calls only. For mobile clients and public read environments.
# - Write: allows inserting (upsert) and deleting (delete) data. For backend-only pipelines.
# - Admin: includes the right to create/delete collections (create_index).

Tip

  • With a SaaS DB such as Pinecone, one stolen API key means all the data can be leaked or tampered with, so never expose the API key in frontend code (React and so on); route requests through your own backend API.
  • ChromaDB for local development has no built-in authentication mechanism, so when deploying to production put a reverse proxy (Nginx and so on) or basic auth in front to control external exposure.

Vector DB practical design

Vector DB practical design is a point where the options diverge. Using the table to compare what each approach is for and how it differs in operation makes later decisions much easier.

Beyond deciding the embedding distance metric and HNSW parameters, vector DB design must include authentication security modeling for SaaS/distributed environments, such as Milvus RBAC and Pinecone API keys.
Decision pointQuestion to askPractical guideline
BoundariesWhich parts of the Vector DB code are most likely to change?Separate input/output, configuration, external integrations, and the core rules.
StateWhere is state created and where does it go away?Make the owner and lifecycle of state visible in the code.
FailureWhat does the caller receive on failure?Decide the timeout, fallback, and error contract first.

Vector DB operating standards

This section covers Vector DB operating standards from a practical perspective. Instead of memorizing the concept, focus on the situations in which you would reach for it.

Control index build memory, monitor p99 latency, and run a key distribution strategy that isolates the tiers of Pinecone API key (Read-Only vs Write vs Admin) to match the nature of each service node.

Tip

  • Whether Pinecone API key scopes are isolated
  • Check Milvus User/Role privilege bindings
  • Tune the HNSW M/ef_construction parameters
  • Verify filtering speed through metadata indexing

Vector DB verification strategy

Vector DB verification strategy is a point where the options diverge. Using the table to compare what each approach is for and how it differs in operation makes later decisions much easier.

Along with recall evaluation and metadata filtering verification, continuously run static security checks that no vector DB master API key is hardcoded in client source code.
Quality axisHow to verifyDefinition of done
CorrectnessAutomate the normal/failure cases.The core scenarios pass reproducibly.
Regression preventionWhen fixing a bug, leave the same case behind as a test.The same failure is not deployed again.
OperabilityCheck the logs, metrics, and alerts.There is a path for tracing the cause when a problem occurs.

Vector DB: frequently asked questions

How is a vector database different from a regular database?

A regular database finds rows whose values match exactly or fall in a range, while a vector database finds data that is similar in meaning. Sentences or images are turned into numeric vectors by an embedding model and stored, then searched for the ones closest to the query vector. Documents with different words but similar meaning can be found, which is why vector databases are used for RAG, recommendations, and similar-image search.

Do I need a dedicated vector database, or is pgvector on PostgreSQL enough?

If you already run PostgreSQL and the number of vectors is not very large, starting with pgvector is easier to operate. You can join with existing data in one query and use transactions. Consider a dedicated vector database when the vector count is very large, when latency and throughput requirements are high, or when you need features such as filtering and sharding.

What happens to existing data when I change the embedding model?

Everything has to be embedded again. Each model has its own dimensions and semantic space, so distances between vectors from different models cannot be compared. Record which model and version produced each vector as metadata, and when changing models build a new index separately, verify it, and then switch over.

What should I check when search results are unrelated to the question?

First check that the chunk size is neither too large nor too small, that the same embedding model is used for questions and documents, and that the model handles the language of your documents well. Then tune the number of results (top-k) and add hybrid search with keyword matching or a reranker. Measure every change against an evaluation set of question and expected-document pairs; otherwise you cannot tell whether it improved.

← Previous guideMongoDB