MySQL UPDATE and SELECT in one pass

后端 未结 6 1356
轮回少年
轮回少年 2020-11-28 14:05

I have a MySQL table of tasks to perform, each row having parameters for a single task.
There are many worker apps (possibly on different machines), performing tasks in

6条回答
  •  执笔经年
    2020-11-28 15:03

    I don't know about the single call part, but what you're describing is a lock. Locks are an essential element of relational databases.

    I don't know the specifics of locking a row, reading it, and then updating it in MySQL, but with a bit of reading of the mysql lock documentation you could do all kinds of lock-based manipulations.

    The postgres documenation of locks has a great example describing exactly what you want to do: lock the table, read the table, modify the table.

提交回复
热议问题