I am reading that document: http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%24mod
$mod
The $mod operator allows you to do fast modulo queries to replace a common case for where clauses. For example, the following $where query:
db.things.find( "this.a % 10 == 1")
can be replaced by:
db.things.find( { a : { $mod : [ 10 , 1 ] } } )
So I didn’t understand what fast means here. Performance?
I have not benchmarked this, but it will probably indeed mean performance. Apparently the “$where” executes javascript for each object, but “$mod” is a mongodb native operator, which should be much faster, because there is no need to execute any javascript for each object. Have also a look at the following sentence from the documentation:
http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-JavascriptExpressionsand%7B%7B%24where%7D%7D