Hi forum members,
I was wondering whether YugabyteDB supports optimistic locking?
If it does, I have the following questions:
- What are the implementation details of it? Does the database read versions from cache or disk?
- How does it impact write performance?
See docs for locking: Explicit locking | YugabyteDB Docs
Depends if the data is already cached in-memory.
One of the transactions gets aborted and has to be retried by the client.
Thanks for your reply @dorian_yugabyte.
Now I have quite a few new questions:
- How can I use optimistic locking in Yugabyte DB?
- Does it have a specific syntax or it will be handled manually and the database will only provides some constructs to speed up the process?
- Is the “For Update” syntax used primarily for pessimistic locking or it can be used solely for optimistic locking as well?
It’s used by default.
See details Explicit locking | YugabyteDB Docs
Hi. I hope you are well.
I’m a new user of Yugabyte DB.
Does using optimistic locking cause read before write?
(If it causes read before write, therefore it reduces performance a lot. Am I right?)
It depends on the query and the full table schema + indexes.