Using AI Features in PostgreSQL
Store, retrieve, and integrate data for AI systems using PostgreSQL
Enroll now for $195 USD !Course Summary
Do you want to start working with AI-related features in PostgreSQL? Or are you going to be asked about using databases this way? Either way, you need to be prepared!
This course is about using PostgreSQL to store, retrieve, and integrate data for AI systems, in a way that is reliable, understandable, and operationally sound. We assume you already understand PostgreSQL fundamentals and are comfortable working with PostgreSQL and database design.
- Are you responsible for deciding where AI-related logic should live, and where it should not?
- Do you need to support vector search, retrieval, or AI integration without turning the database into an experimental system?
- Do you want to understand Data API Builder and configuring an MCP server for PostgreSQL?
- Have you been asked whether databases should be used for embeddings, RAG patterns, or AI orchestration, and wanted a clear answer that you can explain?
If any of that sounds like you, then you’re in the right place. You’ll get clear explanations, hands-on exercises, and short quizzes to make sure you not only understand the concepts but can confidently apply them in real PostgreSQL environments.
And while the practical exercises are optional, we strongly encourage completing them. They are designed to be straightforward and focused on realistic scenarios, rather than tooling complexity. Setup is easy.
Enroll now for $195 USD !
Modules and Lessons
Module 0: Getting Started
Who is this course for ?
Who is Greg ?
What will I learn in this course ?
Configuring your lab environment
Module 1: AI in the context of PostgreSQL
Module introduction
AI features in PostgreSQL
What the database is responsible for
What the database is not responsible for
What the model service is responsible for
Extensions vs PostgreSQL core
Misconceptions to avoid
Positioning PostgreSQL correctly
Lab 1
Lab 1 video walkthroughs
- Exercise 0: Overview
- Exercise 1: Installing PostgreSQL and pgAdmin
- Exercise 2: Installing pgvector
- Exercise 3: Create the aifeatures database and enable pgvector in it
Quiz 1
Module 2: Vector data and embeddings fundamentals
Module introduction
What is an AI model?
What embeddings are and why they exist
How vector similarity differs from relational comparison
Typical AI scenarios that involve vectors
Why vectors work well for these scenarios
When vectors are inappropriate
Where embeddings models are hosted
Common embeddings models
Lab 2
Lab 2 video walkthroughs
- Exercise 0: Overview
- Exercise 1: Installing Ollama
- Exercise 2: Generating and inspecting raw embeddings
Quiz 2
Module 3: Vector data types in PostgreSQL
Module introduction
Vector data type basics
pgvector extension basics
Declaring vector columns and variables
How vector values are represented
Practical table pattern for embeddings
Dimensionality is enforced
Dimensionality changes are migration events
Storage characteristics and limitations of pgvector
Lab 3
Lab 3 video walkthroughs
- Exercise 0: Overview
- Exercise 1: Creating tables with vector data types
Quiz 3
Module 4: Querying vector data
Module introduction
What similarity search means in PostgreSQL
Writing similarity queries in SQL
Vector distance comparison operators
Exact similarity (KNN) vs approximate search (ANN)
Combining vector similarity with relational predicates
Common query mistakes and inefficiencies
Lab 4
Lab 4 video walkthroughs
- Exercise 0: Overview
- Exercise 1: Populating vector columns and executing distance queries
Quiz 4
Module 5: Vector indexing and performance
Module introduction
Why vector indexing exists
HNSW vector indexes
IVFFlat vector indexes
Accuracy versus performance trade-offs
CPU and memory impact of vector queries
Monitoring and diagnosing vector query performance
Lab 5
Lab 5 video walkthroughs
- Exercise 0: Overview
- Exercise 1: Implementing HNSW vector indexes
- Exercise 2: Implementing IVFFlat vector indexes
Quiz 5
Module 6: Integrating External AI Services
Module introduction
Why PostgreSQL might need an external AI service
What REST means in practice
HTTP requests, responses, headers, and status codes
JSON request and response payloads
Endpoints, hosts, ports, and network reachability
Authentication and secrets
Timeouts, throtting, quotas, and cost
Error handling, retries, and idempotency
Operational risks of outbound calls from the database
Quiz 6
Module 7: Calling AI services from PostgreSQL (In development)
Module introduction
Where should AI model calls be made
Synchronous HTTP and asynchronous workflows
HTTP Options from PostgreSQL
Introducing pgsql-http
Running AI models locally with Ollama
Calling Ollama from PostgreSQL with pgsql-http
Processing responses and storing embeddings
Invoking generative and chat models
Handling timeouts, failed requests, and retries
Tracking embedding model and version information
Calling online models from PostgreSQL
Lab 7
Lab 7 video walkthroughs
- Exercise 0: Overview
- Exercise 1: Installing pgsql-http
- Exercise 2: Populating vector columns from a local model
- Exercise 3: Populating vector columns from an online model
Quiz 7
Module 8: Creating AI pipelines (In development)
Module introduction
Why AI enrichment is usually background work
Identifying rows that require processing
Tracking embedding state and model versions
Efficiently finding pending work
Background execution options
Two ways to execute the model call
Durable state and transaction boundaries
Handling retries, concurrency, and idempotency
Re-embedding when content or models change
Monitoring backlog, failures, and throughput
Where a workflow engine might be appropriate
Quiz 8
Module 9: Implementing pipelines on Windows with pgsql-http (In development)
Module introduction
Windows lab architecture
Preparing the Windows extensions
Preparing rows for background embedding
Calling Ollama in batches with pgsql-http
Scheduling background processing with pg_cron
One processing cycle
Observing and recovering the Windows pipeline
Lab 9
Lab 9 video walkthroughs
- Exercise 0: Overview
- Exercise 1: Creating and testing an AI pipeline stored procedure
- Exercise 2: Scheduling the AI pipeline
Quiz 9
Module 10: Implementing pipelines on Unix with pg_net (In development)
Module introduction
Introducing pg_net
Understanding the pg_net reqeust lifecycle
Calling Ollama from PostgreSQL with pg_net
Dispatching batches asynchronously with pg_net
Tracking requests and processing responses
Retry and recovery with pg_net
Choosing between pg_net and pgsql-http
Quiz 10
Module 11: Retrieval-augmented query patterns
Module introduction
What RAG means in practical terms
Executing similarity search in an AI workflow
In-database re-ranking
Passing retrieved data back to the app tier or to LLMs
Lab 11
Lab 11 video walkthroughs
- Exercise 0: Overview
- Exercise 1: Executing an end-to-end RAG query using indexed vectors
Quiz 11
Module 12: Security, governance, and operational concerns
Module introduction
Protecting sensitive data used in AI workflows
Applying PostgreSQL RLS to vector searches
Auditing AI-related queries
Governance boundaries in AI-enabled systems
Quiz 12
Module 13: When NOT to use AI features in PostgreSQL
Module introduction
Why it matters to say no
Scenarios where PostgreSQL is the wrong tool
When a specialized vector database makes more sense
Cost, complexity, and mainteance trade-offs
Decision checklist for architects and DBAs
Quiz 13
Module 14: Using Data API Builder with PostgreSQL
Module introduction
Data API Builder and PostgreSQL
Architecture and configuration for HorzionDB
Exposing tables and other objects via REST and GraphQL
Authentication and security
Lab 14
Lab 14 video walkthroughs
- Exercise 0: Overview
- Exercise 1: Exposing PostgreSQL vector search via a DAB endpoint
Quiz 14
Module 15: Using PostgreSQL with AI Agents via MCP
Module introduction
AI agents and external tools
SQL Server MCP vs PostgreSQL MCP implementation
MCP architecture for PostgreSQL
Example agent workflow querying pgvector data
Lab 15
Lab 15 video walkthroughs
- Exercise 0: Overview
- Exercise 1: Configuring an MCP server to expose PostgreSQL search to a local LLM
Quiz 15
Module 16: Next steps
Summary and further steps
Enroll now for $195 USD !