Databases · DBC-46

PostgreSQL for AI Apps with pgvector

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.

Updated
From 3,510 THB / person 3,900 −10% excl. VAT 7% · group rates available
PDFDownload the course outline
  • Duration6 hours · 1 days
  • FormatOnsite / live online
  • Next roundOn request
  • CertificateIncluded

Course overview

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 1 Embeddings, 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 2 Lab: 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 3 Lab: 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 4 Lab: 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 5 Lab: 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 6 Lab: 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 7 Workshop: 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 8 Lab: 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 9 Running 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 10 Workshop: 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

For organisations — in-house / private

  • Tailor the content to your team’s tools and projects
  • Your dates, at your office or live online
  • Quotation with tax ID for procurement
Corporate training quote

Instructors

Frequently asked questions

Who is PostgreSQL for AI Apps with pgvector for, and what background is needed?

Built 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 Background you should have: Able to write SQL including SELECT, JOIN, CREATE TABLE and CREATE INDEX · Basic Python: functions, installing packages and calling APIs Not sure the fit is right? Talk to our team on LINE @itgenius or call 02-570-8449.

How much does PostgreSQL for AI Apps with pgvector cost and how long does it run?

THB 3,900 (currently THB 3,510 on promotion). The course runs 6 hours. The price excludes 7% VAT (for payment in a company's name). Pay by bank transfer to the company account, confirm it on our payment page, and we can issue the receipt or tax invoice in your company's name.

Do I get a certificate?

Yes. Everyone who completes the course receives a Certificate of Completion from IT Genius Institute. Each certificate carries its own number, and anyone holding that number can verify it online on our certificate page, so you can add it to your portfolio or pass it to HR as evidence of training.

Where does the training take place, and is there an online option?

You can attend onsite at IT Genius Institute or arrange to join online, and we also run it as a private in-house session for your team. Ask about dates and venues on LINE @itgenius or call 02-570-8449.

What if I fall behind or miss a session — can I retake it?

Yes. You may retake the same course free of charge in a later round, under the institute's conditions. Tell our team which course and round you attended, and we will check it and offer you the rounds that still have seats. Ask us on LINE @itgenius or call 02-570-8449.

How do I enrol, or request a quotation for my company?

Enrol online with the registration form on this page. You can register several attendees at once and enter your tax ID and billing address for the tax invoice. Or request a company quotation straight from the quote button. For anything else call 02-570-8449 or reach us on LINE @itgenius.