TL;DR:
I want a table in my database to act as an priority queue (Here a min-queue on ID
), are there any free (for commercial use) DBMS that can solve my problem? And how would a query look like?
I want to have many concurrent users to select a single row from a table, e.g. I have the table
+------+-------+--------+------------+
| ID | Col 1 | Col 2 | Processed |
+------+-------+--------+------------+
| 1000 | data | data | False |
+------+-------+--------+------------+
| 1001 | data | data | False |
+------+-------+--------+------------+
| 1002 | data | data | False |
+------+-------+--------+------------+
and if I have 3 users, I want to do atomic SELECT
and UPDATE
, such that the first query returns Col 1
and Col 2
from the row with the lowest ID
and marks Processed
as True
, such that the the next query would return the row with ID = 1001
.
The table is expected to be small, i.e. at most 100,000 rows and the queue is expected to be emptied in about 8 hours (around 3-4 queries per second, peak might be around 50 queries in a single second). I am used to PostgreSQL/MySQL and have used MongoDB briefly.
How should I design my system to cope with this? How would a query look like? Would a table lock noticable?