Used the "FOR UPDATE SKIP LOCKED LIMIT 1" trick to implement a job server in PG a few years ago for the first time.
It's a great solution.
It's a great solution.
On my first go I was taking batches, on the reasoning that it optimized for query performance. It was a complete disaster and I quickly realized that I was engaging in premature optimization.
Batching is out, stream-processing is in. If you design your job table correctly, PG will perform very well as an advanced stream processor.
https://github.com/davidbanham/kewpie_go
I’ve been using it for years across multiple products.
I also built this for a client lately. It lets them interop their Haskell services with kewpie a bit easier without needing to write a native wrapper.