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:
Javascript executes more slowly than the native operators listed on this page,
but is very flexible.
http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-JavascriptExpressionsand%7B%7B%24where%7D%7D
Any javascript/regex queries in mongodb can't use indexes and work slow. So answer on your question is yes, documentation say about performance.
More info about server side javascript you can find here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With