Free PostgreSQL Course

Most PostgreSQL tutorials
leave you confused.

certuvia teaches PostgreSQL differently. Every lab starts with a realistic scenario — you discover why the command exists before you touch it. A live Linux environment with real PostgreSQL and four preloaded databases runs in your browser. All 104 labs are available; browse the complete curriculum below.

Browse Labs
104Total Labs
104Available Now
0/104Labs Completed
student@lab:~$EXAMPLE
student@lab:~$ psql -h localhost -U postgres -d beer_db
psql (19.0)
beer_db=# SELECT current_database(), current_user;
current_database | current_user
beer_db | postgres
(1 row)
beer_db=# ▊

About this PostgreSQL course

Cost
Free. Access the lessons and browser labs without payment or a credit card.
Format and language
Self-paced, online, and in English. Start anytime and work through practical, text-based lessons at your own pace.
Who it’s for
Beginners learning SQL and developers building PostgreSQL skills. Start with queries, then explore database administration and performance.
What you need
A desktop or laptop with a modern browser and a keyboard. Basic computer skills are enough to start; no SQL experience or local installation is required.
Accounts and progress
No account is needed for lessons. Progress is saved in this browser; an optional account lets you sync completed lessons across devices.
Certificates
Sign in to claim a certificate after completing a track. Certificates record lesson completion, rather than a proctored exam. View certificates.

Questions about the course or a lab? Contact support@certuvia.com.

Everything in one viewport

Lab steps on the left, terminal on the right. No tab-switching, no copy-pasting between windows. Complete each objective and watch the checkmarks fill in.

104
Labs
104
Available Now
100%
Scenario-First

3 certificates. 104 labs. One clear path.

TRACK 1

SQL Developer

Design schemas, write queries, and manage data with confidence.

6 blocks · 28 labs · 10–13 hrs0 / 28 completed
Block 1.1

Connecting & Orienting

The setup phase is where beginners lose confidence. These labs make the environment feel navigable before a single table is created.

Block 1.2

Your First Schema

Types, constraints, and schemas define your data rules. Inspect them, test them, and plan changes carefully.

🏗️Lab 1.2.130 min

CREATE TABLE and Data Types

Choose the right column type — not everything is text or integer

Start lesson →
🔒Lab 1.2.225 min

Constraints That Protect Your Data

Make invalid data impossible to insert — NOT NULL, UNIQUE, CHECK, DEFAULT

Start lesson →
🔗Lab 1.2.325 min

Foreign Keys and Referential Integrity

Link tables with REFERENCES — make orphaned rows impossible

Start lesson →
🔧Lab 1.2.430 min

Altering Tables Safely

Separate storage work from lock waits while changing a table

Start lesson →
📁Lab 1.2.520 min

Schema Organisation

Namespace your tables, set search_path, and lock down public schema access

Start lesson →
🎯Lab 1.2.645 min

ENUM Types, Generated Columns & Numeric Precision

Compare closed-set types, generated values, and decimal arithmetic

Start lesson →
Block 1.3

Querying Data

A query that returns wrong rows is worse than one that returns no rows. Precision over volume.

Block 1.4

Joining Tables

JOINs are where SQL becomes truly expressive. Watch row counts change — that tells you more than any definition.

Block 1.5

Aggregating, Writing, and Transactions

COUNT rows, GROUP BY buckets, write data safely, and wrap changes in transactions that either fully commit or fully roll back.

Block 1.6

Advanced Data Types & Modern SQL Patterns

Inspect JSONB payloads, compare array membership and element counts, test range boundaries and exclusion constraints, and search English lexemes with boolean queries and ranking.

↑ Back to all tracks
TRACK 2

Database Administrator

Configure, monitor, back up, and recover PostgreSQL.

7 blocks · 38 labs · 15–18 hrs0 / 38 completed
Block 2.1

Server Anatomy & Configuration

Inspect cluster storage and configuration, test authentication rules, verify reloads and restarts, and recover a failed startup with pg_ctl.

Block 2.2

Roles, Privileges & Security

Design a least-privilege role hierarchy, close the PUBLIC-access gap, isolate tenants with row-level security, enforce encrypted connections, and understand what real audit logging requires.

👥Lab 2.2.125 min

Roles, Users, and Role Inheritance

Build a role hierarchy, compare inherited access with explicit SET ROLE, and inspect effective identity and object ownership

Start lesson →
🗝️Lab 2.2.225 min

GRANT, REVOKE, and Default Privileges

Replace broad PUBLIC grants with analyst reads, then verify defaults for postgres-created tables

Start lesson →
🛡️Lab 2.2.335 min

Row-Level Security

Test default-deny and tenant filters, expose a caller-controlled context, then enforce a role-bound read/write boundary

Start lesson →
🔒Lab 2.2.428 min

SSL and Encrypted Connections

Enable TLS, require encryption for an application role, and verify the active connection.

Start lesson →
📜Lab 2.2.525 min

Extensions and pgaudit

Install the available pgAudit extension and compare its read auditing with log_statement=ddl.

Start lesson →
Block 2.3

Backup & Recovery

Take logical and physical backups, restore precisely under pressure, migrate roles alongside data, and recover to an exact point in time — every lab ends with a verified, successful restore.

Block 2.4

Monitoring & Observability

Compare access counters, resolve a live lock dependency, inspect heap and index space, verify automatic cleanup, and attribute log, cache, and I/O evidence.

📊Lab 2.4.120 min

Statistics Views and Counters

Compare access counters, interpret a shared-buffer hit ratio, and distinguish a statistics reset from deleting data

Start lesson →
🔒Lab 2.4.222 min

Long-Running Queries and Locks

Keep labelled sessions open, trace a real lock dependency, and compare cancellation with termination

Start lesson →
🎈Lab 2.4.320 min

Table and Index Bloat

Measure heap and B-tree space before deletion, after VACUUM, and after a compact rewrite

Start lesson →
🧹Lab 2.4.420 min

Autovacuum Behaviour and Tuning

Compute a table’s vacuum threshold, apply a local override, and prove a new automatic cleanup occurred

Start lesson →
📜Lab 2.4.520 min

Log Analysis Without pgBadger

Configure duration logging, identify labelled statements in the active CSV log, and rank their observed times

Start lesson →
🧠Lab 2.4.622 min

pg_buffercache & Cache Introspection

Inspect correctly attributed heap buffers, compare occupancy with cumulative hits, and test a larger cache

Start lesson →
💽Lab 2.4.720 min

pg_stat_io: I/O Breakdown

Keep timing enabled for the workload, read relation/WAL and vacuum contexts, and verify cluster-wide reset scope

Start lesson →
Block 2.5

Replication Fundamentals

Inspect WAL, build a physical standby, observe slot retention, compare replay and receipt, and replicate one table between independent clusters.

📡Lab 2.5.120 min

WAL and the Replication Protocol

Read WAL positions and files, then measure cluster-wide WAL across a workload

Start lesson →
🔁Lab 2.5.225 min

Setting Up Streaming Replication

Build a real hot standby from scratch with pg_basebackup -R, start it on port 5433, and confirm it streams

Start lesson →
🎰Lab 2.5.322 min

Replication Slots

Watch a replication slot hold WAL open for a disconnected standby, measure its WAL retention distance, and clean it up safely

Start lesson →
⏱️Lab 2.5.422 min

Monitoring Replication Lag

Pause replay, compare receipt with application, and verify immediate versus delayed commit visibility

Start lesson →
🔀Lab 2.5.525 min

Logical Replication

Migrate a single table live between two independent clusters with CREATE PUBLICATION and CREATE SUBSCRIPTION — no full standby required

Start lesson →
Block 2.6

Maintenance & Upgrades

Compare VACUUM and ANALYZE, measure table rewrites and blocking, reproduce connection limits, rehearse pg_upgrade with one installed version, and verify scheduled maintenance.

🧽Lab 2.6.122 min

VACUUM and ANALYZE Mechanics

Read a real VACUUM VERBOSE output line by line, and watch the visibility map change state before and after

Start lesson →
🔨Lab 2.6.222 min

VACUUM FULL and CLUSTER

Reclaim real disk space with VACUUM FULL, physically reorder a table with CLUSTER, and watch the AccessExclusiveLock block a second session

Start lesson →
🚰Lab 2.6.322 min

Connection Pooling with PgBouncer

Reproduce PostgreSQL connection exhaustion and role limits; read PgBouncer configuration as reference

Start lesson →
⬆️Lab 2.6.425 min

Major Version Upgrade with pg_upgrade

Rehearse pg_upgrade on one installed version, verify copied datasets and roles, and understand the major-version procedure

Start lesson →
📅Lab 2.6.525 min

Maintenance Scheduling and Runbooks

Write a bloat-alert query, a maintenance script, and schedule both with real OS-level cron — no pg_cron required

Start lesson →
Block 2.7

Application Integration & Concurrency Patterns

Push real-time notifications without polling, coordinate work with advisory locks, build a job queue with no external broker, audit every DDL statement automatically, query external sources as local tables, and move application logic into the database itself.

📣Lab 2.7.122 min

LISTEN / NOTIFY: Pub/Sub Messaging

Replace a polling loop with a real push model — and see exactly when a listening client actually notices a message

Start lesson →
🔑Lab 2.7.222 min

Advisory Locks: Application-Level Mutexes

Turn leader election into three lines of SQL, with no external coordination service at all

Start lesson →
📬Lab 2.7.322 min

SKIP LOCKED: Building a Job Queue

Dequeue work atomically with no collisions and no external broker — and see exactly how NOWAIT fails differently

Start lesson →
📋Lab 2.7.422 min

Event Triggers & DDL Auditing

Capture every schema change automatically — and discover firsthand that DROP needs a completely different event to see it

Start lesson →
🌉Lab 2.7.525 min

Foreign Data Wrappers: Querying External Sources

Query a genuinely separate cluster and a plain CSV file as if both were local tables — with real filter pushdown, not just convenience syntax

Start lesson →
⚙️Lab 2.7.625 min

Stored Functions & Procedures in PL/pgSQL

Move twelve round-trips into one transactional procedure — and prove a failed order leaves no partial damage behind

Start lesson →
↑ Back to all tracks
TRACK 3

Performance Engineer

Diagnose slow queries, tune indexes, and scale PostgreSQL.

7 blocks · 38 labs · 18–24 hrs0 / 38 completed
Block 3.1

Understanding the Query Planner

Read EXPLAIN output fluently enough to know exactly why a query is slow — bad row estimates, the wrong join strategy, an unhelpful GUC, or work the planner could parallelize but is not.

🔬Lab 3.1.125 min

EXPLAIN and EXPLAIN ANALYZE

Read a real query plan node by node — and reproduce "30 seconds on production, 0.1 seconds locally" with nothing but a cold cache

Start lesson →
📊Lab 3.1.225 min

Planner Statistics and Bad Estimates

Watch the planner badly misjudge two correlated columns, then fix it with one CREATE STATISTICS object — and measure exactly how much better the estimate gets

Start lesson →
🔀Lab 3.1.325 min

Join Strategies

Force the planner's hand between Nested Loop and Hash Join, and measure exactly what the wrong choice actually costs

Start lesson →
⚙️Lab 3.1.425 min

Planner Configuration and Query Rewrites

No extensions can be installed on this server — fix bad plans with the GUCs and query shapes PostgreSQL already ships with

Start lesson →
🧵Lab 3.1.525 min

Parallel Query and JIT

This VM has exactly one CPU. Find out, with real measurements, whether parallel query and JIT compilation still do anything on it.

Start lesson →
Block 3.2

Index Engineering

Indexes are the single highest-leverage performance tool in a relational database. Design them well and most production slowdowns never happen at all.

🌳Lab 3.2.125 min

B-tree Internals and Multi-Column Indexes

A query filters on (status, created_at). There is already an index on (created_at, status). It is not being used. Prove why, then fix it.

Start lesson →
🔍Lab 3.2.225 min

Partial and Expression Indexes

99% of these rows will never be queried by status again. Index only the 1% that matters, and measure exactly how much smaller that makes it.

Start lesson →
📇Lab 3.2.325 min

Covering Indexes and Index-Only Scans

An Index Only Scan still touched the table heap once. The index was never the problem — the visibility map was.

Start lesson →
📚Lab 3.2.425 min

GIN for Full-Text Search and JSONB

LIKE '%word%' cannot use a B-tree index no matter how it is built. GIN indexes a completely different structure — and actually can.

Start lesson →
📉Lab 3.2.525 min

BRIN, Hash, and Choosing the Right Index Type

500,000 rows in physical time order. A B-tree index on created_at costs 11MB. A BRIN index costs 24kB — for the same query support.

Start lesson →
🔧Lab 3.2.625 min

Index Maintenance and Bloat

Two indexes on the same table. One has never been scanned once. The other is real, measured, 33% fragmented. Find both, and fix only the one that matters.

Start lesson →
🫧Lab 3.2.725 min

Bloom Indexes: Multi-Column Equality at Minimal Cost

Five low-selectivity columns, queried in every combination. Five B-tree indexes cost 10MB combined. One bloom index covers all of them at 3.1MB.

Start lesson →
Block 3.3

Advanced SQL Patterns

Solve complex analytical problems inside the database, where the data already lives, instead of shipping rows across the network to solve them in application code.

🌲Lab 3.3.125 min

CTEs and Recursive Queries

An org chart traversal loops through 7 levels in application code, one database round trip per level. Replace it with one recursive query.

Start lesson →
🪟Lab 3.3.225 min

Window Functions

A 7-day moving average, a cumulative total, and a day-over-day change — all three, plus the raw daily number, without collapsing a single row.

Start lesson →
↪️Lab 3.3.325 min

LATERAL Joins

"For each customer, their 3 most recent orders." One approach costs less on paper. The other one is actually faster, measured.

Start lesson →
📄Lab 3.3.425 min

JSONB: Documents in PostgreSQL

100,000 event payloads stored as JSONB. Query inside them, extract nested values, and index them — all without ever normalizing them into columns.

Start lesson →
📅Lab 3.3.525 min

Arrays and Range Types

A check constraint at the application layer is unreliable. Make double-booking a room structurally impossible at the database level instead.

Start lesson →
🔗Lab 3.3.625 min

Writeable CTEs: Atomic Data Pipelines

SELECT into Python, then INSERT, then DELETE — three round trips, with a real window where data exists in both places or neither. One writeable CTE closes that window completely.

Start lesson →
📊Lab 3.3.725 min

Window Frames, crosstab & Advanced Analytics

A rolling average that silently absorbs an extra day across a data gap. A pivot table for the board. An average computed 46x faster from 1% of the data. Three requests, three real tools.

Start lesson →
Block 3.4

Schema Design for Scale

A schema decision made at design time determines whether a database performs the same way at 100 million rows as it did at 100,000. Every lab here is a real pattern that breaks at scale.

🗂️Lab 3.4.125 min

Table Partitioning

A 2-billion-row logs table full-scans on every date-filtered query, despite an index. Partitioning eliminates the irrelevant 99% before a single row is touched.

Start lesson →
🍞Lab 3.4.225 min

TOAST and Large Column Storage

A common assumption says an unselected large column still silently costs I/O. Checked directly against the real database, that assumption turns out to be wrong — and the real cost lives somewhere more specific.

Start lesson →
🔥Lab 3.4.325 min

HOT Updates and fillfactor

A table taking thousands of updates per second is generating enormous WAL volume and index bloat. HOT updates are the structural fix — when they can happen at all.

Start lesson →
📸Lab 3.4.425 min

Materialized Views and Refresh Strategies

A 90-second aggregation query runs on every page load. A materialized view pre-computes it once — the real challenge is refreshing it without blocking every reader while it happens.

Start lesson →
💽Lab 3.4.525 min

Tablespaces and Storage Placement

Index I/O and table I/O are competing on the same disk, saturating the queue. Moving indexes to a second volume immediately separates the two workloads.

Start lesson →
Block 3.5

Server Configuration Tuning

Configuration tuning is guesswork without a mental model of what each parameter actually controls. This block builds that model against this VM's real, measured hardware — not an imagined 64GB server.

🧠Lab 3.5.125 min

Memory Tuning

Verify shared_buffers with a restart, then compare disk and memory sorts using real query plans.

Start lesson →
⏱️Lab 3.5.225 min

WAL and Checkpoint Tuning

A common reference says checkpoint stats live in pg_stat_bgwriter. Checked directly on this PostgreSQL 19 server, that view no longer has them at all.

Start lesson →
🧵Lab 3.5.325 min

Parallel Query Tuning

The curriculum imagines 16 idle CPU cores. This VM has exactly one, confirmed directly. Tune parallel query anyway — and measure the honest result.

Start lesson →
🔒Lab 3.5.425 min

Connections, Timeouts, and Deadlocks

A connection sits idle inside an open transaction. A query runs forever. Two sessions lock each other out permanently. Three real problems, three real safety timeouts.

Start lesson →
Block 3.6

Diagnostics Under Pressure

Each lab starts with an incident. You are on-call, the SLA is 30 minutes away, and there is no one else to ask. Go.

📈Lab 3.6.125 min

pg_stat_statements: Finding the Real Slow Queries

A developer shows you a query that takes 2 seconds. A different query, called 50,000 times a minute, might be costing far more in total. pg_stat_statements reveals which one actually matters.

Start lesson →
🔗Lab 3.6.225 min

Lock Contention Diagnosis

The application is intermittently slow. Several sessions are waiting on locks. Build the real chain, find the one session actually responsible, and terminate only that one.

Start lesson →
🕵️Lab 3.6.325 min

auto_explain and Slow Query Forensics

A slow query only fires under specific production load and cannot be reproduced in testing. auto_explain captures its real execution plan automatically, the moment it actually happens.

Start lesson →
🌊Lab 3.6.425 min

PgBouncer Tuning and Connection Storms

Black Friday. A real connection storm arrives. PgBouncer is confirmed absent on this server — find out exactly what PostgreSQL itself does, and does not do, when far too many connections arrive at once.

Start lesson →
🚨Lab 3.6.540 min

Disaster Scenario Labs

Four real incidents, back to back, on the same server. A dropped table, a crashed primary, a bloating replication slot, and a transaction ID wraparound check — each one genuinely reproduced, not simulated.

Start lesson →
Block 3.7

Extensions & Real-World Patterns

Five production requests arrive this sprint. A junior engineer reaches for a separate service each time — every one of them is solvable inside PostgreSQL, with an extension already available on this VM.

🔍Lab 3.7.130 min

Fuzzy Search Toolkit: pg_trgm, unaccent & fuzzystrmatch

Customer search is broken three different ways: an accent, a typo, and a phonetic variant. Three genuine extensions fix the three real cases — and they compose into one function.

Start lesson →
📍Lab 3.7.225 min

Geospatial Queries Without PostGIS

The mobile app needs the 5 nearest cafes, a count within a delivery zone, and a point-in-polygon check. PostGIS is confirmed absent on this server — PostgreSQL's own native geometric types genuinely cover all three.

Start lesson →
🧮Lab 3.7.325 min

Custom Aggregates, Ordered-Set & Hypothetical-Set Aggregates

The finance team needs a geometric mean. The risk team needs a 95th percentile. The sales team wants a hypothetical rank without inserting a row. All three are built-in, or writable, directly in SQL.

Start lesson →
📦Lab 3.7.420 min

Table Defragmentation: VACUUM FULL's Real Lock Cost

A table with 18 months of deletes is mostly empty space. pg_repack would reclaim it online — confirmed absent on this server. What VACUUM FULL genuinely costs instead is demonstrated directly.

Start lesson →
📡Lab 3.7.525 min

Logical Decoding & Change Data Capture

A new data warehouse pipeline needs every row change in real time, with no polling and no application code changes. Logical decoding turns the real WAL into a structured change stream.

Start lesson →
↑ Back to all tracks