I need to perform the following on MySQL/InnoDB. Assume I have a table consists of 3 cols (id, counter, status)
I need to:
Requirements:
What would be the best solution in term of performance and scalability (work for large table)?
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
START TRANSACTION;
SELECT id
FROM mytable
WHERE status = 0
FOR UPDATE;
UPDATE mytable
SET status = 1,
cnt = cnt + 1
WHERE status = 0;
COMMIT;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With