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

Adding Equality-Sort-Range info to index documentation

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor - P4
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: manual
    • Labels:
      None

      Description

      Currently, our documentation does not have information that specifically talks about designing indexes using the Equality-Sort-Range rule. The online trainings talk about the E-S-R rule in depth, however the docs do not mention it.

      It would be nice to add a blurb like this one, to our index documentation:

      The optimal index for a given query can usually be found with the equality-sort-range rule, which 
      indicates that in an index, the equality fields should be first, then the sort fields, and finally the range
      fields.
      So, for example, let's consider this query: db.test.find({a:'x', b: {$gt: 10}}).sort(}}{{{c:1}}}
      Here, `a` is an equality based match, `b` is a range based match, and `c` is used for sorting. Following 
      the equality-sort-range rule, the most optimal index for the above query will be: `{a:1, c:1, b:1}`
      

      Scope of Changes

      • A new page possibly under Indexing Strategies to cover ESR
      • Need to frame carefully as a guideline and not an all-encompassing rule

        Attachments

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            harshad.dhavale Harshad Dhavale
            Participants:
            Last commenter:
            Shubham Ranjan
            Votes:
            5 Vote for this issue
            Watchers:
            9 Start watching this issue

              Dates

              Created:
              Updated:
              Days since reply:
              3 weeks, 3 days ago
              Date of 1st Reply: