MongoDB
思sc橙子
这个作者很懒,什么都没留下…
展开
-
MongoDB性能分析
用法1:db.find(……).explain()例:db.test1.find({"instanceId":"ins1"}).explain(){ "queryPlanner" : { "plannerVersion" : 1, "namespace" : "ssc_test.test1", "indexFilterSet" : false, "parsed原创 2021-07-29 22:44:12 · 540 阅读 · 0 评论 -
已经建了唯一索引的字段再和另一个普通字段组合建唯一索引,查询性能有差别吗?
例如cl1对f1建唯一索引,db.cl1.find({“f1”:“xxx”})cl2对f1建唯一索引,再对(f1,f2)建组合索引,db.cl2.find({“f1”:“xxx”,“f2”:“xxx”})理论上,两个查询性能应该是没有区别的,因为f1已经保证唯一了,所以都是n条记录用加了索引的搜索算法找1条,能有什么区别。。...原创 2021-07-28 18:06:20 · 309 阅读 · 0 评论 -
MongoDB常见操作(备忘)
跨数据库复制集合:use <srcDbName>db.<srcClName>.find().forEach(function(d){ db.getSiblingDB("<destDbName>")["<destClName"].insert(d);})连接查询://假设有两个集合user和user_detail,user表的_id对应user_detail表的userId,下面查询name为hhh的全部信息:db.user.aggregat原创 2021-04-16 15:03:32 · 595 阅读 · 0 评论