Optimized way of Querying in MongoDB using $in vs $or

前端 未结 4 1164
别那么骄傲
别那么骄傲 2020-12-03 15:09

Implementing an application that looks up a table for mail id presence from a list of around 10 email ids. Tried using $or and $in.

$in seems to give better performa

4条回答
  •  一个人的身影
    2020-12-03 15:52

    "While "$or"will always work, use "$in"whenever possible as the query optimizer handles it more efficiently."

    Moreover "$in" has more readability.

    Ref: MongoDB: The Definitive Guide

提交回复
热议问题