Why using $all in mongodb is much slower?

前端 未结 1 807
南笙
南笙 2021-01-28 10:14

I asked a similar question before Why $in is much faster than $all? and the answer is the idea that $in (that scan more row and return more result) should be faster due to sorti

相关标签:
1条回答
  • 2021-01-28 10:42

    This is working as designed as answered in Why $in is much faster than $all? as answered.

    $all with only one item is equivalent with normal search right?

    No, it is a different codepath and different operator.

    MongoDB explains the difference here. $all matches all values as opposed to any (which $in does). There are further usage examepls here.

    The relevant SERVER ticket that you want is here. You can vote on this ticket.

    0 讨论(0)
提交回复
热议问题