The question:

I need to query a frequently updated record, does it wait until all updates finish?

  • /updateUser/1

    Many requests are sent

    UPDATE users SET count = count + 1 WHERE id = 1 LIMIT 1
  • /getUser/1

    While the user is being updated i perform this request

    SELECT * from users WHERE id = 1 LIMIT 1

The Solutions:

Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.

Method 1

By default, writers do not block readers. So no, the SELECT would not have to wait for the UPDATE to finish.

Exception cases:

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Comment