I hadn't heard of skip locked before, and very much enjoyed this article walking through it for postgres: https://blog.2ndquadrant.com/what-is-select-skip-locked-for-...
Love the headline "Most work queue implementations in SQL are wrong". That kind of stuff makes me read an article...
This short screencast was also very helpful https://www.pgcasts.com/episodes/7/skip-locked/
Using the database as a queue is an anti-pattern. There used to be an entire blog series about why this is the case. However, I can't find it at the moment.
Re:How do you cut a monolith in half?
by eternalvision on Friday June 30, 2017 @03:02PM
(#14672968)
With MySQL, there's a fairly simple trick you can do to build a queue. Set a temp var to null, run an update with a select subquery to update state of next row(s), then select that var to get your queue row pk's.
* Postgresql and Oracle with skip locked
* MS SQL Server with readpast
* DB2 with skip locked data
If you use MySQL, it's going to be a bit more difficult.