Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-14442

Warn about performance issues with $in

    XMLWordPrintableJSON

Details

    Description

      Description

      Page: https://docs.mongodb.com/manual/reference/operator/query/in/

      There can be some performance issues when passing hundreds or thousands of parameters as a $in array. We should note that this is an anti-pattern and may be solved via a schema redesign.

      Also, we should recommend that an index exists with the field. In the example here,  indexes like {tags: 1} and {qty: 1} would be very beneficial. 

      Scope of changes

      Impact to Other Docs

      MVP (Work and Date)

      Resources (Scope or Design Docs, Invision, etc.)

      Attachments

        Activity

          People

            kenneth.dyer@mongodb.com Kenneth Dyer
            nicholas.cottrell@mongodb.com Nic Cottrell
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              1 year, 49 weeks, 2 days ago