Databases · DBC-51

Advanced PostgreSQL for Enterprise

Advanced PostgreSQL for Enterprise is a hands-on course in running PostgreSQL in production, from query tuning and monitoring with Prometheus and Grafana to point-in-time recovery with pgBackRest, a Patroni high-availability cluster and major version upgrades. It suits DBAs, DevOps engineers and developers who look after databases that must stay available and recoverable.

Updated
From 11,250 THB / person 12,500 −10% excl. VAT 7% · group rates available
PDFDownload the course outline
  • Duration30 hours · 5 days
  • FormatOnsite / live online
  • Next roundOn request
  • CertificateIncluded

Course overview

When an organisation's key systems run on PostgreSQL, getting it installed is not enough. The team needs to know why the database slows down, whether data can be restored to the moment before an incident, and how service carries on when the primary server fails. Many organisations still back up with VM snapshots only, already run Prometheus and Grafana without watching the database with them, and have never rehearsed a failover or a full restore.

This course takes learners through running PostgreSQL in production over 5 days, on a single sample project, the NovaMart Order Platform. It starts with internals such as WAL and MVCC, installs and tunes PostgreSQL 17 on Ubuntu 24.04, tunes queries and indexes and connects the database to Prometheus and Grafana. Learners then build pgBackRest backups that really restore to a point in time, grow the system into a high-availability cluster with Patroni, etcd, HAProxy and PgBouncer, practise an upgrade to PostgreSQL 18, and finish with a Game Day that works through incidents using a runbook. (5 days, 6 hours per day, 30 hours in total, Advanced level.)

What you’ll gain

  • Understand PostgreSQL internals (processes, memory, WAL, MVCC) and use them to analyse performance and data correctness problems
  • Install and tune PostgreSQL 17 on Ubuntu 24.04 to suit the hardware and the workload
  • Analyse execution plans, choose index types and fix slow queries systematically
  • Connect PostgreSQL to Prometheus and Grafana, with key metrics and alert thresholds
  • Design backups that restore to a point in time against RPO/RTO targets, instead of relying on VM snapshots alone
  • Build and run a high-availability cluster with Patroni, etcd, HAProxy and PgBouncer, and test failover
  • Apply least-privilege access, encrypt connections and keep audit logs in line with PDPA
  • Upgrade from PostgreSQL 17 to 18 with minimal downtime and handle incidents with a runbook

Who this course is for

  • Backend and full-stack developers who already use PostgreSQL and need to help run it in production
  • DBAs, system administrators and DevOps engineers responsible for database servers, backup and high availability
  • Tech leads and software architects who design systems for large data volumes and continuous availability
  • Teams moving from VM snapshots to database-level backups that can restore to a point in time
  • Learners who have finished PostgreSQL Administration and want to go deeper into HA, DR and monitoring

Prerequisites

  • Fluent SQL (SELECT, JOIN, GROUP BY, INSERT, UPDATE, DELETE) and an understanding of transactions
  • Experience using PostgreSQL in development or operations; PostgreSQL Administration is a good foundation
  • Basic Linux commands, such as connecting over SSH, moving between directories and editing files with nano or vim
  • No prior experience with Patroni, pgBackRest or Prometheus is needed

Curriculum

Course Details

This is an Advanced course that builds on PostgreSQL Administration and PostgreSQL Administration & SQL Query for Reporting. It focuses on production operations: high availability, backup and disaster recovery, monitoring and alerting, upgrades and incident response, and goes deeper than the foundation courses by having learners build, break and restore real systems. It runs for 5 days, 6 hours per day (30 hours in total, 09:00-16:00), as a continuous workshop on

a single sample project, the NovaMart Order Platform, using generated data only. Labs use three Ubuntu Server 24.04 LTS machines (pg1, pg2, infra). The content is based on PostgreSQL 17 with an upgrade lab to PostgreSQL 18. Lab environment details are confirmed with learners before the class. Learners take home daily lab guides, scripts and configuration files, Grafana dashboards, alert rules and a runbook for 8 common incidents to adapt to their own systems.

Day 1 Internal Architecture, Linux Essentials and Installation

Section 1: Processes, Memory and the Write-Ahead Log

  • The postmaster, backend processes and background workers (checkpointer, background writer, WAL writer, autovacuum launcher)
  • Shared buffers, work_mem and maintenance_work_mem, and how each uses server resources
  • How WAL, checkpoints and full page writes work, and how they tie into backup and replication
  • The PostgreSQL versioning policy: one major release a year and 5 years of support

Section 2: MVCC, Transaction Isolation and Locking

  • Tuple visibility (xmin/xmax) and why PostgreSQL needs VACUUM
  • Read Committed, Repeatable Read and Serializable, and their effect on applications
  • Conflicting row and table lock modes, and inspecting them with pg_locks
  • Lab: demonstrate lock waits and anomalies at each isolation level

Section 3: Lab: Linux Essentials for Database Work

  • Manage services with systemd and read logs with journalctl
  • Check disk space and I/O with df, du and iostat, and inspect memory and processes
  • Users, file permissions and secure SSH key access
  • Lab: health-check an Ubuntu 24.04 server before installing the database

Section 4: Lab: Installing and Tuning PostgreSQL 17

  • Install from the PGDG repository on Ubuntu 24.04 and use the postgresql-common tools (pg_lsclusters, pg_ctlcluster)
  • Enable data checksums when the cluster is created, and why you should
  • postgresql.conf, pg_hba.conf and ALTER SYSTEM, tuning memory, checkpoint and autovacuum settings to the server size
  • Managing extensions and what to watch for during upgrades
  • Lab: tune the primary node against a production checklist

Section 5: Workshop Day 1: Connections, Privileges and PgBouncer

  • Why a high max_connections is dangerous, and PgBouncer session, transaction and statement pooling
  • Role hierarchies with least privilege, and the pg_maintain role added in PostgreSQL 17
  • SCRAM-SHA-256 authentication and enabling SSL/TLS
  • Workshop: create application, read-only and admin roles for NovaMart, enable TLS and deploy PgBouncer
  • Measure with pgbench before and after connection pooling
Day 2 Performance Tuning, Observability and Maintenance

Section 6: EXPLAIN ANALYZE and Planner Statistics

  • Read EXPLAIN (ANALYZE, BUFFERS), including the SERIALIZE and MEMORY options added in PostgreSQL 17
  • Seq scan, index scan, bitmap scan, nested loop, hash join and merge join
  • Find bad row estimates, and use ANALYZE and extended statistics
  • Lab: read the plan of an order report query and find why it is slow

Section 7: Lab: Index Types and Slow Query Analysis

  • B-tree, GIN, GiST, BRIN, partial indexes and covering indexes (INCLUDE)
  • pg_stat_statements, auto_explain and log_min_duration_statement
  • A process from spotting the problem through the fix to proving the result with numbers
  • Lab: tune 5 slow NovaMart queries until they meet the target

Section 8: Lab: Observability with Prometheus and Grafana

  • Key pg_stat views: pg_stat_activity, pg_stat_database, pg_stat_io, pg_stat_checkpointer and pg_locks
  • Install postgres_exporter and node_exporter and connect them to Prometheus
  • Import and customise Grafana dashboards for the database
  • How to connect to the Prometheus and Grafana stack your team already runs
  • Lab: compare results before and after query tuning on the dashboard

Section 9: VACUUM, Bloat and Transaction ID Wraparound

  • Per-table autovacuum tuning, and the new VACUUM memory management in PostgreSQL 17 that uses less memory
  • Measure bloat and remove it with pg_repack without long table locks
  • Monitor age(datfrozenxid), use REINDEX CONCURRENTLY and schedule maintenance
  • Lab: create bloat on the orders table and measure before and after the fix

Section 10: Workshop Day 2: Partitioning and Data Archiving

  • Range, list and hash partitioning, and partition pruning
  • Use pg_partman to create partitions ahead of time automatically
  • DETACH PARTITION CONCURRENTLY and moving old data to separate storage
  • Workshop: convert the NovaMart orders table into a monthly partitioned table and follow the result in Grafana
Day 3 Backup, Recovery and Security

Section 11: VM Snapshots versus Database Backups

  • Limits of VM snapshots: data consistency, no restore to an arbitrary point in time, and an RPO tied to the snapshot schedule
  • Using VM snapshots and database backups so that they complement each other
  • Deriving RPO/RTO from business requirements
  • A conceptual comparison of pgBackRest and Barman

Section 12: Lab: Logical and Physical Backups and PITR

  • pg_dump / pg_restore and where they still fit
  • Incremental pg_basebackup, added in PostgreSQL 17, with pg_combinebackup
  • Set up WAL archiving and point-in-time recovery with recovery_target_time and timelines
  • Lab: take an incremental backup, combine it and restore it on a test server

Section 13: Lab: pgBackRest and DR Drills

  • Full, differential and incremental backups, parallel backup, compression and encryption
  • Retention policies and a repository on S3-compatible storage (MinIO)
  • Verify integrity with pgbackrest verify, pg_amcheck and data checksums
  • Run a restore drill, measure the real RTO and set a schedule for backup testing
  • Lab: configure pgBackRest with MinIO and take a full backup of NovaMart

Section 14: Security and PDPA

  • Row-Level Security (RLS) by user or tenant, and its effect on performance
  • pgAudit and choosing a sensible audit scope
  • Column-level encryption with pgcrypto, and data masking
  • A checklist of technical measures for personal data under PDPA

Section 15: Workshop Day 3: Recovering from an Accidental Delete

  • The instructor simulates an accidental delete of NovaMart order data
  • Find the time of the incident in the logs and restore with pgBackRest PITR to just before it
  • Check data correctness and measure the RTO actually achieved
  • Workshop: enable RLS and pgAudit on the customer tables
Day 4 Replication, High Availability and Alerting

Section 16: Streaming and Logical Replication

  • Asynchronous and synchronous streaming replication and their effect on latency and RPO
  • Replication slots, the risk of a full disk from a stale slot, and max_slot_wal_keep_size
  • Logical replication and logical slot failover, added in PostgreSQL 17
  • Lab: build a replica on pg2 and measure replication lag

Section 17: Lab: Automatic Failover with Patroni and etcd

  • DCS architecture, the leader lock and configuring patroni.yml
  • Set up a 3-node etcd cluster on pg1, pg2 and infra
  • Use patronictl for automatic failover and planned switchover
  • Change PostgreSQL settings with patronictl edit-config and rebuild a replica with Patroni bootstrap
  • Lab: bring the existing primary under Patroni without losing data

Section 18: Load Balancing and Preventing Split-Brain

  • HAProxy health checks through the Patroni REST API, with separate read-write and read-only ports
  • Running PgBouncer with HAProxy and what it means for application code
  • etcd quorum and rehearsing network partitions with ufw on Ubuntu
  • Lab: cut one node off the network and confirm that no split-brain occurs

Section 19: Lab: Alerting and Log Analysis

  • Key metrics: replication lag, connection saturation, transaction ID age, disk usage and long-running transactions
  • Write alert rules in Prometheus and route notifications through Alertmanager
  • Configure logging and analyse logs with pgBadger
  • Lab: create an HA alert rule set and test that it really fires

Section 20: Workshop Day 4: The NovaMart HA Cluster

  • Grow the system into Patroni (primary on pg1, replica on pg2) with a 3-node etcd cluster
  • Put HAProxy and PgBouncer in front of the cluster
  • Add a Grafana dashboard for cluster status
  • Workshop: stop the primary while pgbench is running, measure failover time and check that alerts fire correctly
  • Record failover time, replication lag and the measured impact on the application in the workbook
Day 5 Upgrades, Troubleshooting, Kubernetes and Game Day

Section 21: Lab: Upgrading and Migrating from 17 to 18

  • Minor upgrades and the release cycle: PostgreSQL 17 is supported until November 2029 and 18 until November 2030
  • Major upgrade with pg_upgrade in a Patroni cluster, and PostgreSQL 18 changes to know, such as data checksums on by default and statistics carried over
  • Minimal-downtime upgrades with logical replication and pg_createsubscriber
  • Sync the data, verify correctness, cut over and plan the rollback
  • Lab: upgrade the NovaMart cluster to PostgreSQL 18

Section 22: Lab: Locks, Queries and Resource Usage

  • Lock contention and deadlocks: pg_locks, pg_blocking_pids, lock_timeout and statement_timeout
  • Long-running and idle-in-transaction sessions that hold back VACUUM
  • Queries with abnormal resource use, and stopping them safely with pg_cancel_backend and pg_terminate_backend
  • Lab: trace a query that locks a table using Grafana and pg_stat_activity

Section 23: Troubleshooting and Runbooks

  • A full disk from WAL, logs or a stale replication slot: finding the cause and fixing it
  • High replication lag: separating network, disk and long-running queries on the replica
  • Data corruption: checking with pg_amcheck and the recovery options (demonstration)
  • What a good runbook contains: symptoms, checks, fix steps and escalation criteria
  • Write runbooks for 8 common incidents

Section 24: PostgreSQL on Kubernetes (Demonstration)

  • The Kubernetes operator idea and a CloudNativePG demo: create a cluster, fail over and back up to object storage
  • Running PostgreSQL on VMs compared with Kubernetes, and decision criteria
  • Storage, backup and major upgrade considerations when running on Kubernetes
  • Approaches for moving databases from VMs to Kubernetes

Section 25: Master Workshop: Game Day

  • Learners work in teams of 3 on a chain of incidents on the cluster built over days 1-4
  • Simulated incidents: primary failure, high replication lag, a query locking a table, a nearly full disk and an accidental delete
  • Detect each one from Grafana and alerts, then fix it with the runbook
  • Restore with pgBackRest and report the RPO/RTO actually achieved
  • Wrap up the lessons learned and a checklist for applying them to real systems

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 does this course differ from PostgreSQL Administration and PostgreSQL Administration & SQL Query for Reporting?

PostgreSQL Administration is a 3-day course that lays a broad foundation across all DBA tasks, while PostgreSQL Administration & SQL Query for Reporting focuses on SQL for reports and leaves out HA. This course is the Advanced step above both. It spends 5 days on production work only: backup and PITR with pgBackRest including DR drills, an HA cluster with Patroni, etcd, HAProxy and PgBouncer, monitoring and alerting with Prometheus and Grafana, minimal-downtime upgrades, and a Game Day where learners handle real incidents on the cluster they built.

Why does the course use PostgreSQL 17 and upgrade to 18, rather than starting on 18?

Many production systems still run PostgreSQL 17, which is supported until November 2029, so starting on 17 matches what learners meet at work. It also lets learners practise a major upgrade to PostgreSQL 18, the latest stable release, supported until November 2030, both with pg_upgrade in a Patroni cluster and with minimal-downtime logical replication. PostgreSQL 19 was still in beta in October 2026, so it is covered as an overview only.

We already back up with VM snapshots. Do we still need pgBackRest?

VM snapshots are useful for restoring a whole server, but the database may not be consistent at the moment of the snapshot, and you can only go back to the times a snapshot was taken. If someone deletes data by mistake in the afternoon, you cannot return to just before it. pgBackRest with WAL archiving restores to any point in time, verifies backups and applies retention that matches your RPO/RTO. The course shows how to use both together and runs real restore drills with measured RTO.

Do I need Linux administration or DBA experience beforehand?

You do not need to be a DBA, but you should write SQL fluently, have used PostgreSQL in real work and know basic Linux commands, such as connecting over SSH and editing files with nano or vim. Day 1 includes Linux essentials for database work, covering systemd, journalctl and checking disk and memory. No prior experience with Patroni, pgBackRest or Prometheus is needed. Having completed PostgreSQL Administration gives the smoothest start.

What is the lab environment, and what do learners need to prepare?

Labs use three Ubuntu Server 24.04 LTS machines: pg1 and pg2 for PostgreSQL, Patroni and etcd, and an infra machine for the third etcd member, HAProxy, PgBouncer, MinIO, Prometheus and Grafana. Each has 2 vCPUs, 4 GB RAM and an 80 GB SSD. Lab environment details are confirmed with learners before the class. Learners bring a laptop with an SSH client, such as Windows Terminal or VS Code Remote-SSH, and a web browser for Grafana, and should check that their network allows SSH and HTTPS to the lab machines.

Does the course include hands-on labs for PostgreSQL on Kubernetes?

Kubernetes is covered as an instructor demonstration with guidance, not as a hands-on lab. The instructor shows CloudNativePG creating a cluster, failing over and backing up to object storage, then compares running PostgreSQL on VMs and on Kubernetes, with decision criteria and storage, backup and upgrade considerations. Most of the course time goes to the VM-based cluster, a common setup in many organisations.