One NoSQL use case

Simon Willison turned up an interesting NoSQL use case in a crowdsourcing application he built for the Guardian. In the first application he built he used MySQL’s ORDER BY RAND(), which is rather inefficient. (For more on its inefficiency, see the comments on this blog post.) The next time around, he outsourced picking out random results to in-memory database Redis:

The system maintains a redis set of all IDs that needed to be reviewed for an assignment to be complete, and a separate set of IDs of all pages had been reviewed. It then uses redis set intersection (the SDIFFSTORE command) to create a set of unreviewed pages for the current assignment and then SRANDMEMBER to pick one of those pages.

Clever.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>