4 ms·
The row may not exists. OP wants to update a row or create it.
by amirouche 13y ago
The row may not exists. OP wants to update a row or create it.
- pedrocr 13y agoYou mean that with current semantics if you do a "delete from table where id=X" and X doesn't exist you don't get a lock on that id? So why not just change that or add a "lock my_table in id=X" syntax. Isn't what's needed here fine grained locking by row id?
- jeltz 13y agoYou are correct, and the solutions I have read are based around locking the index entry when doing an upsert. The question is how it is best done. Simplified explanations: one solution is to insert a row and lock the new row, another solution is to lock the index entry itself.
- pedrocr 13y agoThanks for the answer. I'm sure there's plenty of complexity I'm missing here. It just seems like having an ID-indexed set of mutexes shouldn't be too hard. Does anyone have a good link discussing the design tradeoffs for a performant upsert?