6 ms·
As long as you don't need a strict priority and a worker can just grab the next waiting job: SELECT * FROM jobs ORDER BY RANDOM() LIMIT 1 SKIP LOCKED should
by karldcampbell 3y ago
As long as you don't need a strict priority and a worker can just grab the next waiting job:
SELECT * FROM jobs ORDER BY RANDOM() LIMIT 1 SKIP LOCKED
should do the trick
- gnud 3y agoThis will give more resources to tenants that schedule more jobs. If tenant A schedules 99 jobs and tenant B schedules 1 job, a "fair" algorithm would pick B's job either first or second, RANDOM() will not.