This book teaches vector databases by building AI systems with PostgreSQL and pgvector. You need no database, SQL, vector, or machine-learning background. You will begin with one tiny similarity query, then progressively master ingestion, hybrid retrieval, RAG, agent memory, evaluation, security, operations, scaling, and architecture through runnable labs and three capstones.
An AI-native system treats models as probabilistic components inside ordinary software. Its database must preserve truth, permissions, provenance, and change while supporting semantic retrieval. That is why this book teaches vector search together with relational joins, full-text search, transactions, row-level security, backups, evaluation, citations, and human approval.
Vector similarity can locate related records. It cannot prove that a passage is true, current, authorized, sufficient, or safe to follow. The surrounding system supplies those guarantees.
Read Parts 1–3 in order and type every command. Complete the small exercises before using an AI framework. Parts 4–6 turn the database into ingestion, retrieval, RAG, and memory systems. Parts 7–9 teach production engineering. Part 10 proves your skills through capstones and gives you operational reference material.
Experienced readers may jump to a part, but should still read the exact-search and evaluation chapters. Approximate indexes are easy to create and surprisingly easy to evaluate incorrectly.
For each lab, use this loop:
Do not paste a large AI-generated application and call it learning. Ask the assistant for one small artifact, inspect it, run it, and explain the result.
The primary learning environment is PostgreSQL with pgvector, psql, Python, Git, and Docker. TypeScript examples appear where they add a useful application boundary. Provider-specific embedding or generation calls sit behind interfaces so you can use an approved service or a local model. Unit tests use deterministic vectors and do not require paid APIs.
Lab baseline: 20 minutes to orient · Cost: free locally · Cleanup: none. Keep a private learning repository, but never commit .env files or credentials.
Create learning-log.md outside the published book. After each part, record:
Expertise is not chapter completion. It is the ability to make a decision, predict consequences, and verify the running system.
The most common failure is optimizing the visible demo while ignoring the lifecycle. Documents change, permissions change, model versions change, caches outlive access, indexes trade recall for speed, and generated answers can sound certain while being unsupported. Every production chapter therefore asks who owns truth, how deletion propagates, what is measured, and how the system recovers.
I am beginning a pgvector learning path. Interview me with five short questions about my operating system, SQL experience, programming language, AI application goal, and available weekly time. Then propose a study schedule using the ten parts of this book. Do not skip Parts 1–3. Include one observable artifact and one verification checkpoint per week.
Verification contract: Ensure the schedule includes exact search before ANN, retrieval evaluation before RAG tuning, security before multi-tenancy, and operations before launch.