| ▲ | bijowo1676 an hour ago | ||||||||||||||||||||||
there is no need to lock the row, since you a dealing with a shopping cart, not individual item piece. when you run aggregate functions, lock is no needed, it is actually better to run it with SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; for aggregation the check for oversold items is extremely cheap:
assuming there are indexes on sku field in both, results in efficient index seek and agg over 2 tables | |||||||||||||||||||||||
| ▲ | edoceo 6 minutes ago | parent | next [-] | ||||||||||||||||||||||
Thanks! I don't uSe 'with' enough | |||||||||||||||||||||||
| ▲ | soontimes an hour ago | parent | prev [-] | ||||||||||||||||||||||
I don’t understand how this should prevent oversold. You have a check that reports empty or oversold inventory. But how does that check prevent 2 concurrent actors fighting for the last item from inserting 2 rows? | |||||||||||||||||||||||
| |||||||||||||||||||||||