MongoDB执行优化的问题

影子传说_Hades 影子传说_Hades 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
When you have a sequence with $sort followed by a
$skip followed by a $limit, an optimization occurs that moves the $limit operator before the $skip operator.
For example, if the pipeline consists of the following stages:
{ $sort: { age : -1 } },
{ $skip: 10 },
{ $limit: 5 }
During the optimization phase, the optimizer transforms the sequence to the following:
{ $sort: { age : -1 } },
{ $limit: 15 }
{ $skip: 10 }


上面为什么要把$limit放在$skip前就能起优化作用呢?
...全文

相关推荐

评论 2
收藏 已收藏
分享
返回顶部
影子传说_Hades
MongoDB 1,797 成员 1,466 内容