mongodb - SQL: Select first and update - for concurrent users -


tl;dr: want table in database act priority queue (here min-queue on id), there free (for commercial use) dbms can solve problem? , how query like?

i want have many concurrent users select single row table, e.g. have table

+------+-------+--------+------------+ | id   | col 1 | col 2  | processed  | +------+-------+--------+------------+ | 1000 | data  | data   | false      | +------+-------+--------+------------+ | 1001 | data  | data   | false      | +------+-------+--------+------------+ | 1002 | data  | data   | false      | +------+-------+--------+------------+ 

and if have 3 users, want atomic select , update, such first query returns col 1 , col 2 row lowest id , marks processed true, such the next query return row id = 1001.

the table expected small, i.e. @ 100,000 rows , queue expected emptied in 8 hours (around 3-4 queries per second, peak might around 50 queries in single second). used postgresql/mysql , have used mongodb briefly.

how should design system cope this? how query like? table lock noticable?

i think postgresql should candidate this.

some interesting pointers:

unless missing something, each thread select update (with skip row locked) picks first non-locked row , locks else, processes it, , flags / deletes once done.


Comments