Labels

biology (1) compilation (1) couchdb (2) database (2) golang (1) google maps (1) mapnificent (1) nosql (2) optimization (1) public transit (1) python (2) randomization (1) sea snake (1) sqlite (1)
Showing posts with label randomization. Show all posts
Showing posts with label randomization. Show all posts

Saturday, March 26, 2011

Cleaner pseudo-randomized views in CouchDB

Lately I've been running into several explanations on how to efficiently get random documents out a Couch database, and so far, the majority of the approaches settle on storing a random value in the document itself, as demonstrated here. This seems like a waste (it adds administrative clutter to the document).

Of course, it's an understandable approach, since couch view functions are required to be idempotent (running the same function with the same input must produce the same output), and at face value, you'd think that generating a random number in the view function would produce different results each time, even with the same input. However, that's not necessarily the case.