I'm still unable to figure out how SQL statements execute in parallel without messing each other's work. I understand the ACID principle in general, but I'm struggling to understand it on particular cases. For example, in the snippet below, could the value of bar.max_count not reflect the actual maximum value of count in table foo when the UPDATE is being executed? (for example, if someone updates or inserts new rows in table foo between the WITH statement and the UPDATE statement).
WITH
bar AS (
SELECT id, MAX(count) AS max_count
FROM foo
GROUP BY id
)
UPDATE mytable
SET count = bar.max_count
FROM bar
WHERE mytable.id = bar.id
In other words: would this statement "block" other concurrent statements that attempt to write in table foo?
Thank you