SQL Advanced: Queries That Hold Up Under Load
Read query plans, choose the right index and change live tables safely. You will read an EXPLAIN ANALYZE plan line by line, pick between B-tree, GIN, GiST and BRIN indexes, understand MVCC, locks and deadlocks, and run migrations and backups that you have proved on a copy. If you skip the plans, the locks and the restore test, your queries will pass on a small table and fail when the table is large and busy.
Course access
-
Reading Plans (empty)3Lessons · 25 min
-
EXPLAIN ANALYZE: Reading a Plan Line by Line
Read a plan from the inside out, compare estimated rows with actual rows, and see what loops, filters and sorts really cost. After this, you can tell which node of a slow query does the work.
10 min -
Statistics, ANALYZE and Why the Planner Guesses Wrong
See what ANALYZE stores, how missing or stale statistics give a wrong plan, and how CREATE STATISTICS fixes columns that depend on each other. After this, you know what to try before you rewrite a query.
10 min -
-
-
Indexes That Earn Their Cost (empty)3Lessons · 25 min
-
B-tree, Partial and Expression Indexes
Build multicolumn, covering, partial and expression indexes, and see when the planner can and cannot use them. After this, you can design one index that serves several queries and costs less to keep.
10 min -
GIN, GiST and BRIN: When a B-tree Is the Wrong Tool
Match a question to an index type, from arrays and text search to overlap rules and very large ordered tables. After this, you can pick an index that fits the question instead of forcing it through a B-tree.
10 min -
-
-
Concurrency (empty)3Lessons · 25 min
-
MVCC, VACUUM and Table Bloat
Look at row versions inside a table, watch dead rows pile up, and see what VACUUM can and cannot remove. After this, you know why a table grows and which sessions stop it from being cleaned.
10 min -
Locks, SELECT FOR UPDATE and Deadlocks
Reproduce a lost update, lock rows with FOR UPDATE, see who is waiting, and cause and fix a deadlock with two sessions. After this, you can find a blocked query and keep lock order safe.
10 min -
-
-
Advanced Query Shapes (empty)3Lessons · 25 min
-
Recursive CTEs and Hierarchies
Walk a category tree down and up, add up a whole branch, and stop a loop in the data with CYCLE. After this, a query follows any depth and does not run forever on bad rows.
10 min -
JSONB: Query Semi-Structured Data Without Regretting It
Read, search, index and change JSONB documents, and see what you give up compared with real columns. After this, you can decide which keys deserve a column and which can stay in the document.
10 min -
-
-
Running It in Production (empty)4Lessons · 35 min
-
Partitioning Large Tables
Split a table by month, see partition pruning in the plan, and remove old data with DETACH and DROP. After this, you know when partitioning helps and which keys and queries it needs.
10 min -
Changing a Live Table Without Locking It
Use lock_timeout, tell a quick change from a table rewrite, read lock modes from pg_locks, and add NOT NULL and foreign keys in two steps. After this, a migration waits its turn instead of stopping the application.
10 min -
Backup, Restore and Proving the Restore Works
Take a logical and a physical backup in Docker, restore both, and prove the data matches with counts and a checksum. After this, you have a backup that you have tested and not just written.
10 min -
-
-
Final Check: SQL Advanced (empty)1Lessons · 15 min
-
About
Read query plans, choose the right index and change live tables safely. You will read an EXPLAIN ANALYZE plan line by line, pick between B-tree, GIN, GiST and BRIN indexes, understand MVCC, locks and deadlocks, and run migrations and backups that you have proved on a copy. If you skip the plans, the locks and the restore test, your queries will pass on a small table and fail when the table is large and busy.
- Responsible
- Mary Q
- Last Update
- 09/27/2026
- Completion Time
- 2 h 30 min
- Members
- 1
Reviews
Sign in to write a reviewComments
Sign in to commentNo comments yet.