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

Please document how Partial vs. Sparse compound indexes work

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Won't Do
    • Icon: Major - P3 Major - P3
    • Server_Docs_20231030
    • None
    • Server
    • None

    Description

      On this page you describe how a sparse single-key index can be represented as a partial index:

      https://docs.mongodb.com/manual/core/index-partial/#std-label-index-type-partial

      However, there is no documentation for how sparse compound indexes can be represented as an equivalent partial index.

      For example, is the index:

      db.contacts.createIndex(
         { name: 1, email: 1 },
         { sparse: true }
      )
      

       the same as:

      db.contacts.createIndex(
         { name: 1, email: 1 },
         { partialFilterExpression: { name: { $exists: true }, email: { $exists: true } } }
      )
      

      In my understanding, sparse implies an OR condition (name exists OR email exists), however it doesn't seem partial supports OR.

      (*If we cannot get the same functionality using partial, then it should not be said that "partial is a superset of sparse")

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            shields@tablecheck.com Johnny Shields
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              41 weeks, 6 days ago