Databases · DBC-02-06

PostgreSQL for Developers

PostgreSQL for Developers is a course in using PostgreSQL 18 from the developer's side, from schema design, modern SQL and JSONB to reading EXPLAIN plans, choosing indexes, writing PL/pgSQL and working through an ORM. It suits backend and full-stack developers, and those moving from MySQL or SQL Server, who want a fast and correct database.

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

Course overview

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 ORM. As data grows they run into slow queries, stuck locks, bad data that no constraint caught, or code that quietly opens the door to SQL injection, even though PostgreSQL already ships with the tools to prevent all of this.

This course shows developers how to use PostgreSQL 18 the way it is meant to be used. Learners install it with Docker, choose the right data types, including the new uuidv7() function and virtual generated columns, design schemas that protect data with constraints, and write modern SQL with CTEs, window functions, MERGE, RETURNING OLD/NEW and JSONB. The course then digs into performance with EXPLAIN, the different index types, pg_stat_statements, transactions and locking, before taking everything into real applications with Node.js, Prisma or Drizzle, Row-Level Security, LISTEN/NOTIFY and pgvector. It closes with a project that designs and tunes the database of an application end to end. (3 days, 6 hours per day, 18 hours in total, Intermediate level.)

What you’ll gain

  • Install and run PostgreSQL 18 with Docker alongside psql, pgAdmin 4 or DBeaver
  • Choose data types and design schemas that use constraints to keep data correct
  • Write modern SQL fluently, including CTEs, window functions, LATERAL, MERGE and ON CONFLICT
  • Store and search JSONB data and use full-text search efficiently
  • Read query plans from EXPLAIN and design indexes that match query patterns
  • Understand transactions, MVCC and isolation levels, and avoid deadlocks
  • Connect applications safely through connection pooling, ORMs and migrations
  • Apply Row-Level Security, LISTEN/NOTIFY and pgvector in real applications

Who this course is for

  • Backend and full-stack developers who use PostgreSQL or are about to adopt it in a project
  • Developers moving from MySQL or SQL Server who want to get the most out of PostgreSQL
  • Data engineers and API engineers who write queries and look after database performance
  • Tech leads who review the team's schema design, migrations and queries
  • Anyone who wants to go beyond basic SQL and run a database confidently in production

Prerequisites

  • Basic SQL such as SELECT, JOIN, GROUP BY, INSERT and UPDATE
  • Programming experience in at least one language; JavaScript or TypeScript is a plus
  • Basic command-line and Git skills
  • A laptop that can run Docker Desktop, Node.js and VS Code, with permission to install software

Curriculum

Course Details

This course is a new edition that replaces the previous PostgreSQL for developers course. It has been rewritten from scratch and updated for PostgreSQL 18. It runs for 3 days, 6 hours per day (18 hours in total, 09:00-16:00), as lectures with labs built on a single sample online store database throughout. Intermediate level. Every lab runs on the learner's own machine with Docker, using only open source tools. The course takes an application developer's point of view, covering schema design, SQL, performance tuning and using the database from code. It does not cover DBA operations such as replication or production backup. Learners take home a lab guide, SQL files and sample code for every lab, and docker-compose files for PostgreSQL 18, PgBouncer and pgAdmin.

Day 1 Solid Foundations and Modern SQL

Section 1: Lab: Getting Started with PostgreSQL 18 on Docker

  • Why developers choose PostgreSQL and how it differs from MySQL and SQL Server
  • What is new in PostgreSQL 18 for developers, and a look at what PostgreSQL 19 will bring
  • Install PostgreSQL 18 with Docker Compose, with volumes and sensible defaults
  • Work fluently in psql and manage databases with pgAdmin 4 or DBeaver
  • Databases, schemas, roles and basic privileges for an application

Section 2: Choosing the Right Data Types

  • Identity column primary keys compared with uuid and uuidv7() in PostgreSQL 18
  • numeric versus float for money, and timestamptz versus time zone bugs
  • text, varchar and collations, and how they affect sorting and searching Thai text
  • Arrays, enums, ranges and domains, and the caveats of each
  • Common pitfalls when moving data types over from MySQL or SQL Server

Section 3: Schema Design and Constraints

  • Normalizing just enough, and where denormalizing is worth it
  • Protect data with NOT NULL, CHECK, UNIQUE and foreign keys with ON DELETE
  • Exclusion constraints to prevent overlapping bookings
  • Virtual generated columns (the default in PostgreSQL 18) compared with stored ones
  • Lab: design an online store schema with a full set of constraints

Section 4: Lab: Modern SQL in Practice

  • CTEs and recursive CTEs for hierarchical data
  • Window functions: ROW_NUMBER, RANK, LAG, LEAD and running totals
  • LATERAL joins, FILTER and GROUPING SETS for multi-dimensional reports
  • INSERT ... ON CONFLICT and MERGE, including MERGE ... RETURNING
  • The new RETURNING that can reference OLD and NEW values in PostgreSQL 18

Section 5: Lab: JSONB and Full-Text Search

  • When to store data as JSONB and when to split it into columns
  • JSONB operators, jsonpath and GIN indexes
  • Turn JSON into rows with JSON_TABLE and build JSON with SQL/JSON constructors
  • Full-text search basics: tsvector, tsquery and ranking results
  • Lab: search products by JSONB attributes and description text
Day 2 Performance, Transactions and Logic in the Database

Section 6: The Query Planner and EXPLAIN

  • How the planner chooses a plan: statistics, cost and ANALYZE
  • Read EXPLAIN (ANALYZE, BUFFERS) line by line to find where time goes
  • Seq scans, index scans, bitmap scans and the different join methods
  • Enable pg_stat_statements to find the queries with the highest total time
  • Lab: track down slow queries in a sample app and measure before and after

Section 7: Lab: Designing Indexes That Match Your Queries

  • Composite B-tree indexes and getting the column order right
  • Partial, expression and covering indexes with INCLUDE
  • B-tree skip scan in PostgreSQL 18 and what it changes for index design
  • Choosing GIN, GiST or BRIN for the data type at hand
  • Why an index is not used, and the cost of having too many indexes

Section 8: Transactions, MVCC and Locking

  • How MVCC works and why VACUUM is needed
  • Isolation levels: Read Committed, Repeatable Read and Serializable
  • Row locks, SELECT ... FOR UPDATE and finding locks that are held too long
  • What causes deadlocks and how to write code that avoids them
  • Lab: build a job queue with FOR UPDATE SKIP LOCKED

Section 9: PL/pgSQL, Procedures and Triggers

  • Write functions and procedures in PL/pgSQL with error handling
  • Triggers for audit logs and keeping updated_at current
  • SQL functions compared with PL/pgSQL, and function volatility
  • Criteria for deciding which logic belongs in the database and which in the app

Section 10: Views, Materialized Views and Partitioning

  • Views to hide complexity and limit what data is visible
  • Materialized views and REFRESH ... CONCURRENTLY
  • Declarative range and list partitioning for large tables
  • Partition pruning and choosing a partition key that fits the queries
  • Lab: partition a log table by month and test the result
Day 3 PostgreSQL in Real Applications

Section 11: Connecting from Applications Safely and Fast

  • The cost of a connection and the idea behind connection pooling
  • PgBouncer from the developer's side: session versus transaction mode and their limits
  • Prepared statements, parameterized queries and preventing SQL injection
  • Setting timeouts and handling database errors in code
  • Lab: put PgBouncer in front of the app and test it under many concurrent requests

Section 12: Lab: ORMs and Migrations with Node.js

  • Connect PostgreSQL to Node.js and TypeScript with Prisma and Drizzle
  • Versioned migrations and changing a schema without long table locks
  • The N+1 query problem and how to spot it in the logs
  • When to stop relying on the ORM and write raw SQL safely

Section 13: Lab: Row-Level Security and LISTEN/NOTIFY

  • Design a multi-tenant application with Row-Level Security
  • Write policies and pass the user's tenant from the app into the database
  • Test that each tenant's data cannot leak to another
  • LISTEN/NOTIFY for pushing real-time change notifications to the app

Section 14: pgvector and AI Assistants for SQL

  • Store embeddings in a vector column with the pgvector extension
  • Build an HNSW index and run similarity search with distance operators
  • Combine vector search with ordinary SQL filters in one application
  • Use AI assistants to write and explain SQL, and verify the result before using it
  • Lab: find similar products from embeddings of their descriptions

Section 15: Lab: Testing and Capstone Project

  • Test database code with Docker and repeatable seed scripts
  • Capstone: design the database of a small app from schema to indexes
  • Measure with EXPLAIN and tune until it meets the targets you set
  • Present the work, review it together and wrap up with 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

How do you read EXPLAIN ANALYZE output in PostgreSQL?

Read from the most deeply nested node upwards, since that step runs first, and compare the planner's estimated rows with the actual rows; a large gap usually means statistics are stale and ANALYZE should be run. Then find the node with the highest actual time and check whether it is a sequential scan on a large table. Adding the BUFFERS option shows how much data came from memory rather than disk.

When should you store data as JSONB instead of separate columns?

JSONB suits data whose structure varies from row to row, such as attributes that differ by product type or payloads received from external APIs. Data that every row shares, that needs constraints or foreign keys, or that is filtered and joined often belongs in ordinary columns. When you do use JSONB, add a GIN index so containment queries with operators such as @> stay fast.

How do you set up row-level security for a multi-tenant app in PostgreSQL?

Add a tenant_id column to every table that must be separated and enable row-level security on those tables. Then write policies that compare tenant_id with a value the app sets for each transaction, for example through set_config and current_setting. Connect the app with a role that does not own the tables, because owners bypass policies by default, and test that no tenant can see another tenant's rows. The course practises this in a lab.

Who is the PostgreSQL for Developers course for, and what should I know beforehand?

It suits backend and full-stack developers who use or are about to use PostgreSQL, developers moving from MySQL or SQL Server, and data engineers and tech leads who review their team's schemas and queries. You should be able to write basic SQL such as SELECT, JOIN and GROUP BY, program in at least one language, and use the command line and Git at a basic level.

What will I be able to do after the PostgreSQL for Developers course?

You will be able to design schemas that use constraints to protect data, write modern SQL with CTEs, window functions and MERGE, read EXPLAIN plans to choose the right indexes, and connect applications safely through a connection pool and an ORM, as well as use row-level security and pgvector in real apps. 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 Developers course?

Bring a laptop that can run Docker Desktop, Node.js and VS Code, with permission to install software, because every lab runs on your own machine in Docker using PostgreSQL 18 with psql and pgAdmin 4 or DBeaver. You take home the lab guide, SQL files, sample code and a docker-compose file for PostgreSQL 18, PgBouncer and pgAdmin.