Queue Implementation with Custom Consistent Absolute Ordering


I need to create a schema for a queue. Elements in this queue will be processed in an order based on a column. However, this is not always the e.g. date_added column. Users should be able to freely re-order items in the queue, thus setting a custom position – let’s call that field position. Therefore, queue items that have a position >= to the new position I set for a specific item need to be re-ordered on each update.

I really want to avoid using a server-side script to manually go through each of the now outdated elements and updating their position. Is there a way to do this automatically, and with relatively low resource usage? I’m sure people have implemented such a queue in MySQL before, but there don’t seem to be relevant answers anywhere, although the task sounds trivial. Any ideas?

Go to Source
Author: XedinUnknown