我正在阅读该文档:http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%24mod
$mod
$mod 运算符允许您进行快速模查询以替换 where 子句的常见情况。例如,下面的 $where 查询:
db.things.find( "this.a % 10 == 1")
可以替换为:
db.things.find( { a : { $mod : [ 10 , 1 ] } } )
所以我不明白 fast
在这里是什么意思。性能?
最佳答案
我没有对此进行基准测试,但它可能确实意味着性能。显然 "$where"为每个对象执行 javascript,但 "$mod"是一个 mongodb 本地运算符,它应该快得多,因为不需要为每个对象执行任何 javascript。还请查看文档中的以下句子:
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
https://stackoverflow.com/questions/7765355/
相关文章:
mongodb - 您将如何使用文档存储(例如 CouchDB、Redis、MongoDB、Riak
ruby-on-rails - Mongoid `group()` 条件
mongodb - 紧凑命令未释放 MongoDB 2.0 中的空间
python - 如何使用 MongoKit 对远程数据库主机进行身份验证?
mongodb - 在 MongoDB 中使用 directoryperdb 的好处
php - 将数据从关系数据库反规范化到非关系数据库的最佳实践
python - Pymongo 断言错误 : ids don't match