Menu
Back to Discussions

You can use optimistic locking without a specific version field when your data naturally includes a timestamp or a unique hash that updates with every change. For example, if you have a `last_updated` timestamp column that automatically gets updated on every record modification. You just need some field that reliably changes every time the record is modified. But if you dont have that, you should probably add a version field.

Fares Mansour
Fares Mansour
·1164 views
Hey everyone, I'm thinking about performance for a new service. So, we've got a situation where updates happen a lot, but conflicts hardly ever do. Putting a version column on every single table just feels like too much. Has anyone tried optimistic locking just by checking some key fields in the WHERE clause when they update something? I'm curious if all that field comparing actually slows things down more than it helps by not having a special version field. Or maybe there are other weird problems I'm not seeing. What do you all think about this? When is it okay, and when is it a bad idea?
1 comment

Comments

Loading comments...