AI Hints
Home›PostgreSQL Tutorial
Free course

PostgreSQL Tutorial

Learn PostgreSQL from zero, one small and easy step at a time. Every idea is explained in plain words, then shown as real SQL in psql and real Python code, run against a real PostgreSQL 18 database with real output.

📚 120 lessons▶ 1:49:08+ of video💻 125 code examples🖼 0 screenshots
The complete PostgreSQL course, free on YouTubeWatch on YouTube ↗

Course contents

Every lesson has its own page with the explanation, code you can copy, the real output, screenshots from the video, and a link that jumps straight to that moment in the video.

6. Creating Tables

  1. CREATE TABLE13:09
  2. Identity Columns14:08
  3. Constraints14:59

7. Foreign Keys and RETURNING

  1. Foreign Keys15:51
  2. INSERT ... RETURNING16:52
  3. UPDATE and DELETE ... RETURNING17:44

8. Upsert, Generated Columns, ALTER

  1. Upsert with ON CONFLICT18:20
  2. Generated Columns19:14
  3. ALTER TABLE20:05

9. Joins, LATERAL and FILTER

  1. Joins Refresher20:55
  2. LATERAL Joins21:54
  3. Aggregates and FILTER22:49

10. ROLLUP and CTEs

  1. GROUPING SETS and ROLLUP23:44
  2. CTEs24:46
  3. Recursive CTEs25:41

12. DISTINCT ON, generate_series, Report

  1. DISTINCT ON29:33
  2. generate_series30:25
  3. Practice: The Monthly Report31:21

15. Updating and Building JSON

  1. Updating JSONB37:26
  2. Building JSON38:18
  3. JSONB or Columns?39:11

16. Enums, UUIDs and Ranges

  1. Enums and Domains39:58
  2. UUIDs40:56
  3. Range Types41:53

17. Indexes and EXPLAIN

  1. How Indexes Work42:52
  2. B-tree Indexes43:50
  3. EXPLAIN44:41

18. EXPLAIN ANALYZE and Smarter Indexes

  1. EXPLAIN ANALYZE45:33
  2. Multicolumn Indexes46:36
  3. Partial and Expression Indexes47:38

19. GIN, BRIN and Index Mistakes

  1. GIN Indexes48:33
  2. BRIN Indexes49:33
  3. Index Mistakes50:25

21. Fast Search, Fuzzy Search, Practice

  1. A Search Column and Index54:35
  2. Fuzzy Search with pg_trgm55:32
  3. Practice: Book Search56:32

22. Transactions and MVCC

  1. Transactions57:23
  2. Savepoints58:23
  3. MVCC59:14

23. Isolation, Locks and Job Queues

  1. Isolation Levels1:00:14
  2. Locks and Deadlocks1:01:15
  3. FOR UPDATE SKIP LOCKED1:02:11

24. Views and Schemas

  1. Views1:03:09
  2. Materialized Views1:04:01
  3. Schemas and search_path1:04:52

25. Functions and Procedures

  1. SQL Functions1:05:45
  2. PL/pgSQL1:06:43
  3. Procedures1:07:33

27. Roles, Privileges and Row-Level Security

  1. Roles and Privileges1:11:05
  2. Row-Level Security1:11:54
  3. Practice: Shop Staff Access1:12:51

28. Postgres from Python

  1. psycopg Basics1:13:46
  2. Parameters and SQL Injection1:14:43
  3. Transactions in Python1:15:43

29. COPY, Pools and a Python Report

  1. COPY and Bulk Loading1:16:39
  2. Connection Pools1:17:34
  3. Practice: A Python Report1:18:25

30. Partitioning, VACUUM and Statistics

  1. Partitioning1:19:11
  2. VACUUM and Autovacuum1:20:10
  3. Statistics and ANALYZE1:21:01

31. Finding and Fixing Slow Queries

  1. pg_stat_statements1:21:56
  2. A Slow Query Workflow1:22:55
  3. Configuration Basics1:23:52

32. Backups and Replication

  1. Backups with pg_dump1:24:43
  2. Restore and Point-in-Time Recovery1:25:41
  3. Replication1:26:35

33. NOTIFY, Extensions and pgvector

  1. LISTEN and NOTIFY1:27:31
  2. Extensions1:28:26
  3. pgvector1:29:20

34. Vector Search in Postgres

  1. Vector Search1:30:16
  2. Vector Indexes1:31:19
  3. Hybrid Search1:32:20

35. Job Queues, Mistakes and Alternatives

  1. Postgres as a Job Queue1:33:26
  2. Common Mistakes1:34:28
  3. Postgres vs Other Databases1:35:32

36. Project: Harbor Events, Part 1

  1. Project: Harbor Events, the Schema1:36:30
  2. Project: Load and Check1:37:28
  3. Project: Core Queries1:38:17

37. Project: Harbor Events, Part 2

  1. Project: Reports1:38:57
  2. Project: Search1:39:46
  3. Project: Speed It Up1:40:36

38. Project: Harbor Events, Part 3

  1. Project: Safe Bookings1:41:24
  2. Project: Access Rules1:42:22
  3. Project: Python Service1:43:09

39. Interview Questions and Quiz

  1. Interview Questions, Part 11:43:58
  2. Interview Questions, Part 21:45:01
  3. Quick Quiz1:45:52

40. Cheat Sheet, Roadmap and Wrap-up

  1. Cheat Sheet1:47:23
  2. Your Roadmap1:48:26
  3. Wrap-up1:49:08