Skip to content

Tasks · Constraints

Add a foreign key to a live pair of tables

The change

orders.customer_id should reference customers.id. Doing it in one statement locks both tables against writes for the length of a full scan. Keep blocked writes under a second.

routine8 minutesblocked-writes budget 1s simulatedpar 0.5s

Reading your progress…