PostgreSQL for AI Apps with pgvector is a hands-on workshop in building semantic search and retrieval-augmented generation on PostgreSQL with pgvector, from creating embeddings and choosing HNSW or IVFFlat indexes to hybrid search and measuring retrieval quality. It suits backend and AI developers already using PostgreSQL.
Semantic search and RAG have become features many organizations want in their applications, but adding a separate vector database means keeping data in sync across two systems, managing access control twice and taking on more operational work. For teams already running PostgreSQL, the pgvector extension keeps vectors next to business data in the same database, lets you query them with familiar SQL, and reuses the transactions, backups and permissions you already have.
This hands-on course starts with running PostgreSQL 18 and pgvector in Docker, creating embeddings from documents in Python, and choosing the right data types and indexes for your data size. Learners tune HNSW and IVFFlat parameters, build hybrid search that combines full-text search with vectors, isolate each customer's data with Row-Level Security, and build a RAG pipeline that cites its sources. The day closes with measuring retrieval quality, running the system in production, and a document Q&A workshop. (1 day, 6 hours, Intermediate level.)
What you’ll gain
Explain embeddings and similarity measures: cosine, L2 and inner product
Judge when vectors belong in PostgreSQL and when a dedicated vector database is the better fit
Install PostgreSQL 18 with pgvector and choose between the vector, halfvec and sparsevec types
Create embeddings from documents in Python, chunk them and load them into the database
Build and tune HNSW and IVFFlat indexes, including for filtered queries
Build hybrid search and isolate each tenant's data with Row-Level Security
Build a RAG pipeline that retrieves from PostgreSQL and answers with cited sources
Measure retrieval quality and performance, and plan how to operate the system in production
Who this course is for
Backend and AI developers building semantic search or RAG features
Teams already on PostgreSQL who do not want to add a separate vector database
Data engineers who maintain data pipelines and prepare data for AI systems
Tech leads and architects choosing how their team should store vectors
Prerequisites
Able to write SQL including SELECT, JOIN, CREATE TABLE and CREATE INDEX
Basic Python: functions, installing packages and calling APIs
Basic Docker commands and comfort with the command line
An API key for an embeddings/LLM provider, or readiness to use the local model option prepared by the instructor
No machine learning background is needed
Curriculum
Course Details
A 1-day, 6-hour hands-on course (09:00-16:00) at Intermediate level for people who can write SQL and Python, using PostgreSQL 18 and pgvector 0.8.x on Docker. Learners bring an API key for an embeddings/LLM provider or use a local model running on their own machine. Learners take home the course handbook, a Docker Compose file, SQL scripts, Python code for chunking, embeddings, hybrid search and the RAG pipeline, a test question set with a Recall@k script, and a pre-production checklist.
Day 1: Building Semantic Search and RAG on PostgreSQL
Section 1Embeddings, Vector Search and Why PostgreSQL
What embeddings are and why text with similar meaning ends up close together in vector space
Similarity measures: cosine distance, L2 distance and inner product, and which to choose
Vectors in PostgreSQL versus a dedicated vector database: data consistency, permissions and operations
Limits to know: data size, index memory and query throughput
Section 2Lab: Installing PostgreSQL 18 and pgvector
Run PostgreSQL 18 with pgvector using Docker Compose and enable it with CREATE EXTENSION vector
The vector, halfvec and sparsevec types, and choosing one for your data size and dimensions
Binary quantization with the bit type and two-stage search to cut memory use
Lab: create documents and chunks tables and query them with all three distance operators
Section 3Lab: Creating Embeddings in Python and Loading Documents
Call an embeddings API or a local open-source model from Python
Chunking: by size, by heading, and setting overlap between chunks
Store the metadata you need, such as source, page, date and model version
Lab: batch-load documents quickly with psycopg 3 and COPY
Section 4Lab: Exact vs Approximate Search and Indexes
Exact search with a sequential scan versus approximate nearest neighbor search
HNSW: the m, ef_construction and hnsw.ef_search parameters and their effect on accuracy and speed
IVFFlat: setting lists and ivfflat.probes, and why the table needs data before you build the index
Iterative index scans in pgvector 0.8 for queries with WHERE filters
Lab: build both index types and compare timing and results against exact search
Section 5Lab: Hybrid Search with Full-text Search
Where vector search struggles: proper names, product codes and abbreviations
Full-text search with tsvector, tsquery and a GIN index
Combine both result sets with Reciprocal Rank Fusion in a single SQL statement
Lab: compare vector, keyword and hybrid results for the same set of questions
Section 6Lab: Metadata Filtering and Multi-tenancy with RLS
Design metadata and JSONB columns for filtering by type, date and permission
Partial indexes and partitioning when groups of data differ greatly in size
Row-Level Security so each tenant's searches only see their own data
Lab: verify that users in different tenants cannot see each other's documents
Section 7Workshop: Building a RAG Pipeline in Python
The RAG flow: take a question, embed it, retrieve relevant chunks and assemble the context
Prompt the LLM to answer only from the context and to say when the answer is not found
Attach the sources for each answer, such as document name and page
Workshop: build a small Q&A API that retrieves from PostgreSQL
Section 8Lab: Measuring Retrieval Quality and Performance
Build a test question set with correct answers taken from real documents
Measure Recall@k and compare the effect of changes to chunking, indexes and hybrid search
Read EXPLAIN ANALYZE to see whether a query uses the index and where it is slow
Lab: tune ef_search and probes and record accuracy against query time
Section 9Running It in Production
Index build time and memory, maintenance_work_mem and parallel builds
Updating documents, removing old data and re-embedding when you change models
Backup, restore and replication for tables that hold vectors
Managed services that support pgvector, such as Supabase, Neon and Amazon RDS
Optional: exposing the database to an AI agent over MCP safely with a read-only role
Section 10Workshop: Document Q&A over Your Own Documents
Workshop: take the sample document set or your own documents from chunking through to indexing
Test real questions, check the cited sources and fix what search misses
Wrap up with how to apply this to your own systems and a pre-production checklist
Schedule & training options
For individuals — public rounds
No public rounds are open right now. Join the waiting list and we will contact you first when the next round opens, or ask us on LINE. Or call 02-570-8449 or 088-807-9770
What is an embedding, and how is it used for semantic search?
An embedding turns text or other data into a vector of numbers in which items with similar meaning sit close together. Semantic search converts the question into an embedding with the same model and finds the nearest documents using cosine distance, L2 distance or inner product, so it can find relevant passages even when they use different words from the question.
How do HNSW and IVFFlat indexes differ in pgvector?
Both are approximate nearest neighbour indexes. HNSW builds a layered graph and usually gives better recall and query speed, but uses more memory and takes longer to build; it is tuned with m, ef_construction and hnsw.ef_search. IVFFlat splits vectors into clusters set by lists, builds faster and uses less memory, but the table needs data before you create it, and recall is tuned with ivfflat.probes.
What are the steps to build RAG on PostgreSQL?
Split documents into chunks, create an embedding for each chunk and store it in a vector column with metadata such as source and page. When a question arrives, embed it, retrieve the nearest chunks from PostgreSQL and assemble them into context for the LLM, with a prompt telling it to answer only from that context and to cite its sources. The course builds every step in Python.
Who is the PostgreSQL for AI Apps with pgvector course for, and what should I know beforehand?
It suits backend and AI developers building semantic search or RAG features, teams already on PostgreSQL who do not want to add a separate vector database, and data engineers preparing data for AI systems. You should write SQL up to SELECT, JOIN and CREATE INDEX, write basic Python and use Docker at a basic level. No machine learning experience is needed.
What will I be able to do after the PostgreSQL for AI Apps with pgvector course?
You will be able to embed documents and load them into PostgreSQL, choose and tune HNSW or IVFFlat indexes, combine vector and full-text search, separate tenants with row-level security, and build a RAG pipeline that cites its sources, measuring retrieval quality with Recall@k. Participants who complete the training receive a Certificate of Completion with its own number, which can be verified online.
What do I need to prepare for the PostgreSQL for AI Apps with pgvector course?
Bring a laptop that can run Docker and Python, since the labs use PostgreSQL 18 with pgvector 0.8 in Docker, and have an API key for an embedding or LLM provider ready, or use a local model on your machine instead. You take home the Docker Compose file, SQL scripts and Python code for chunking, embeddings, hybrid search and RAG.
PostgreSQL has become the first-choice database for modern applications, from backend systems and SaaS products to workloads that keep JSON or vector data alongside relational tables. Yet many developers still treat PostgreSQL as a generic database behind an…
General AI models are strong at language but do not know your organization's internal information - manuals, policies, contracts, customer data or accumulated know-how. When asked something specific to the organization, AI often answers incorrectly…
Traditional automation follows conditions written in advance, so it stalls on a message that does not fit the pattern or a question that needs data from several places. Agentic AI changes this by letting an LLM interpret the request, plan, and choose which…
18 hours3 days
7,110THB7,900 THB
View details
PostgreSQL for AI Apps with pgvector6 hrs · 1 days