先将数据放入内存在排序(增大内存) db.adminCommand({setParameter:1, internalQueryExecMaxBlockingSortBytes:335544320}) db.article_urls.count({"contentStatus":{$in:[-1,1,2,3,4]}}) db.article_urls.count({"contentStatus":0}) //contentStatus字段不存在的记录数 db.article_urls.count({"contentStatus":{$exists:false}}) //删除mid字段 db.wechat_article_content.update({},{$unset:{"mid":""}},false,true) //将appMsgId字段修改为mid db.wechat_article_content.update({}, {$rename : {"appMsgId" : "mid"}}, false, true) //重命名 db.article_dynamic_data.update({},{$rename:{"likeAauthorImgs":"likeAuthorImgs"}},false,true); //article_urls中contentStatus字段不存在的脏数据 db.article_urls.updateMany({"contentStatus":{$exists:false}},{$set:{"contentStatus":NumberInt(0)}}) //创建索引 db.wechat_article_content.createIndex({"fetchTime":-1}); db.wechat_article_content.createIndex({"fetchTime":1}); db.TEST.totalIndexSize() db.wechat_article_content.getIndexes() db.wechat_article_comment.aggregate([ {$lookup:{from:'wechat_article_content', localField:'articleId', foreignField:'_id', as:'article' }}, {$match:{"_id":"210514751111823373"}}, {$project:{"_id":1,"nickName":1,"content":1,"article.title":1}} ]) { "_id" : "210514751111823373", "nickName" : "苟小薇", "content" : "现在的银行员工确实是在全意全意为客户着想", "article" : [ { "title" : "机警的银行柜员" } ] }