Skip to content
RED SAG Skills
hard20 pts · first answer countstransactionsrow-lockssql

FOR UPDATE on a join locks too much

This query should lock only the order row, but it also locks the customer row and blocks unrelated updates to customers. How do you fix it?

SELECT o.*, c.name FROM orders o
JOIN customers c ON c.id = o.customer_id
WHERE o.id = 101 FOR UPDATE;
Choose one answer

Discussion 0

Join free to post in the discussion.

Related questions