Bruce Momjian Senior Database Architect Dec 5, 2017
You might be aware that Postgres uses invisible columns to track concurrent row access and modifications. My mvcc talk covers much of this.
Someone at a conference mentioned they were using the invisible xmin column to perform updates. I was initially skeptical of this approach, but once he explained the purpose, it made sense, e.g.:
Why would you do this? Normally this would be done using select ... for update. However, what if you want to do the update without locking the row between select and update, and are willing to discard the update if the row has already been updated by another session? This is a case where using xmin in updates makes sense.
(Article originally published on Bruce's blog on Wednesday, October 4, 2017 @ https://momjian.us/main/blogs/pgblog/2017.html#October_4_2017)
Bruce Momjian is a co-founder of the PostgreSQL Global Development Group, and has worked on PostgreSQL since 1996 as a committer and community leader. He is a frequent speaker and Postgres evangelist and travels worldwide appearing at conferences to help educate the community on the business value of Postgres advances and new technology enhancements. He is the author of PostgreSQL: Introduction and Concepts, published by Addison-Wesley.