30 Days of AIDay 12 of 30 · Week 2: Applied AI & APIs
Course outline▾

Week 3 · Infrastructure & Hosting

  1. Day 15Introduction to AI Infrastructure: Hardware, Runtimes, and ComputeComing soon · 2026-10-15 · 7 PM IST
  2. Day 16Local Model Execution: Running Open-Weight LLMs Securely (Ollama, vLLM)Coming soon · 2026-10-16 · 7 PM IST
  3. Day 17Containerizing AI Workloads: Writing Production Dockerfiles for Python APIsComing soon · 2026-10-17 · 7 PM IST
  4. Day 18Docker Compose for Multi-Container AI Stacks (Web UI, Vector DB, LLM Engine)Coming soon · 2026-10-18 · 7 PM IST
  5. Day 19Kubernetes for AI 101: Pods, Deployments, and Services for Model ServingComing soon · 2026-10-19 · 7 PM IST
  6. Day 20Persistent Storage in Kubernetes: Managing State, Weights, and Vector IndicesComing soon · 2026-10-20 · 7 PM IST
  7. Day 21High-Performance Networking: Configuring Ingress and Egress for AI ClustersComing soon · 2026-10-21 · 7 PM IST

Week 4 · Enterprise Workflows

  1. Day 22Autonomous Agents: From Passive LLMs to Goal-Driven ExecutionComing soon · 2026-10-22 · 7 PM IST
  2. Day 23Tool Use & Function Calling: Connecting LLMs to APIs, Databases, and ShellsComing soon · 2026-10-23 · 7 PM IST
  3. Day 24Multi-Agent Orchestration: Supervisor, Worker, and Evaluator PatternsComing soon · 2026-10-24 · 7 PM IST
  4. Day 25Automated CI/CD: Automating the Software Lifecycle for AI ModelsComing soon · 2026-10-25 · 7 PM IST
  5. Day 26Zero-Trust Security for AI: Sandboxing Ephemeral Execution & Model EgressComing soon · 2026-10-26 · 7 PM IST
  6. Day 27Observability & Tracing for Agentic Systems (Telemetry, Logs, and Metrics)Coming soon · 2026-10-27 · 7 PM IST
  7. Day 28Human-in-the-Loop Architecture: Machine Second, Human First in PracticeComing soon · 2026-10-28 · 7 PM IST
  8. Day 29Managing Technical Debt, Drift, and Model Governance in Enterprise ITComing soon · 2026-10-29 · 7 PM IST
  9. Day 30The 10-Year Horizon: Architecting IT Strategy for the AI-Native EnterpriseComing soon · 2026-10-30 · 7 PM IST
Open the course page →

Day 12: Vector Databases — Storing and Searching Enterprise Knowledge

2026-10-12 · 9 min read

Watch the video lesson, or subscribe on YouTube for a new lesson every day.

Yesterday you turned text into embeddings. Now you have a new problem: where do millions of those vectors live, and how do you find the closest ones to a question fast?

In plain terms: A normal database is a filing cabinet with labelled folders. You ask for the folder called "open" and it hands it over. A vector database is a librarian who understands what you mean and brings the books that are closest to your idea, even if no label matches.

Two kinds of question Relational databasePostgreSQL, MySQLWHERE status = 'open'Answer: exact matchyes or noVector databaseMilvus, Qdrant, Pineconeclosest to this meaningAnswer: nearest neighboursranked by distanceEmbeddings need geometry, not keyword matching.A vector database is built to store and index millions of embeddings.
A relational database answers exact-match questions. A vector database answers the question closest to this meaning by ranking stored embeddings by distance, which standard databases are not built to index.

1. The vector store

Standard relational databases such as PostgreSQL or MySQL are built to search for exact matches: WHERE status = 'open'. They have no efficient way to answer "which stored vectors are closest to this one?" That job needs geometry. A vector database such as Milvus, Qdrant or Pinecone is engineered to store and index millions of embeddings and to answer that question efficiently.

2. Approximate nearest neighbour (ANN)

You could compare your question against every stored vector, but at a million documents that is far too slow. Vector databases build an index instead. HNSW (Hierarchical Navigable Small World) is a popular one: it links vectors into a layered graph, so a search starts at a coarse layer and hops closer and closer to the answer. The trade is a little accuracy for a lot of speed, which is why it is called approximate.

Skip the full scan with an index Brute forceANN index (HNSW)Compare against every vector1,000,000 comparisonsHop through a layered graphabout a few dozen comparisonsANN returns the closest matches, not always the perfect ones.Counts are illustrative; real numbers depend on the index settings.
Comparing a query against every vector is too slow at scale. Approximate nearest neighbour indexes such as HNSW hop through a layered graph to reach close matches in milliseconds, trading a little accuracy for a lot of speed. The comparison counts are illustrative.

3. pgvector: no new system required

If your team already runs PostgreSQL and does not want another database to operate, the pgvector extension adds a vector column type and similarity search to it. Your embeddings sit right next to your normal relational data, so one query can filter by customer and rank by meaning.

Where do the vectors live? Standalone vector DBMilvus, Qdrant, PineconeBuilt for millions of vectorspgvector extensioninside PostgreSQLVectors next to your SQL dataLocal libraryfor small experimentsIn memory, no server to runPick by scale: start small, move to a dedicated store when you grow.
You can store embeddings in a dedicated vector database such as Milvus, Qdrant or Pinecone, in PostgreSQL with the pgvector extension next to your regular data, or in a local library for small experiments.

Here is a complete pgvector example. The three-number vectors are only there to keep it short; real embeddings have hundreds of dimensions, and the vector(3) size would match your model's output.

CREATE EXTENSION IF NOT EXISTS vector;

CREATE TABLE docs (
  id        serial PRIMARY KEY,
  body      text,
  embedding vector(3)          -- use your model's size, e.g. vector(1536)
);

INSERT INTO docs (body, embedding) VALUES
  ('High latency on the web tier',   '[0.82, -0.11, 0.47]'),
  ('Packets dropped at the switch',  '[0.79, -0.08, 0.51]'),
  ('Quarterly revenue forecast',     '[-0.12, 0.55, 0.20]');

-- An index makes this fast at scale (HNSW with cosine distance):
CREATE INDEX ON docs USING hnsw (embedding vector_cosine_ops);

-- The 2 paragraphs closest in meaning to the question's vector.
-- <=> is cosine distance: smaller means closer.
SELECT body
FROM docs
ORDER BY embedding <=> '[0.80, -0.10, 0.49]'
LIMIT 2;

Put it together and a query looks like this: embed the question, ask the vector database for the nearest vectors, and get the matching paragraphs back.

A query, end to end Question Why is the site slow? Embedding model text to vector Vector database find nearest vectors Top matches 3 closest paragraphs Milliseconds, even over millions of stored vectors.
A question is turned into a vector by the embedding model, the vector database finds the nearest stored vectors, and the matching paragraphs come back ranked by closeness.

Coming Up Next

Day 13: Retrieval-Augmented Generation (RAG): chatting with proprietary documents.

#VectorDatabase #DataScience #DataArchitecture #BackendEngineering #AI