Skip to Content
0 likes
Find and Fix a Deadlock Level: Advanced

Reproduce a deadlock between two money transfers, read the message, and fix it by locking rows in the same order. After this, you can turn a deadlock detected error into a plain wait.

0 likes
Process a Job Queue With SKIP LOCKED Level: Advanced

Let two workers take different jobs from one table with FOR UPDATE SKIP LOCKED, and see what happens to a job when a worker fails. After this, you can use a plain table as a safe queue.

0 likes
Add a NOT NULL Column to a Big Table Without Downtime Level: Advanced

Add a NOT NULL column to a big table with a constant default, or with a nullable column, a batch backfill, NOT VALID and VALIDATE. After this, you can tell a quick change from a table rewrite and avoid long locks.

0 likes
Walk a Tree With a Recursive CTE Level: Advanced

Walk down an employee tree, walk up to the top, count each manager's team and guard the query against a loop with CYCLE. After this, you can query a parent-child table of any depth.

0 likes
Back Up With pg_dump and Prove the Restore Works Level: Advanced

Take a pg_dump backup in Docker, restore it into a scratch database, compare the tables and see what a damaged backup looks like. After this, you have a short routine that proves your backup works.