3 ms·
Consider the op, "put me in line if the line isn't full" Query 1: Check if the line is full. Query 2: Conditionally put me in line. First, this requires two t
by jhugg 10y ago
Consider the op, "put me in line if the line isn't full"
Query 1: Check if the line is full.
Query 2: Conditionally put me in line.
First, this requires two trips.
Second, the line could fill up between these two trips, cause the second line to put you in a full line.
So, you hold a lock between the two statements. Now you have a third round trip to commit or abort, and the line is frozen for new additions while you talk over the network for two more round trips.
Some examples are better, some worse, but this kind of thing is way better if you bundle up the logic and send it in one round trip.