Using a database table as a queue

前端 未结 9 2232
既然无缘
既然无缘 2020-12-02 07:45

I want to use a database table as a queue. I want to insert in it and take elements from it in the inserted order (FIFO). My main consideration is performance because I have

9条回答
  •  南笙
    南笙 (楼主)
    2020-12-02 08:45

    If you do not remove your processed rows, then you are going to need some sort of flag that indicates that a row has already been processed.

    Put an index on that flag, and on the column you are going to order by.

    Partition your table over that flag, so the dequeued transactions are not clogging up your queries.

    If you would really get 1.000 messages every second, that would result in 86.400.000 rows a day. You might want to think of some way to clean up old rows.

提交回复
热议问题