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

Provide methodological way of thinking about indexes

    XMLWordPrintableJSON

Details

    • Icon: Task Task
    • Resolution: Won't Fix
    • Icon: Major - P3 Major - P3
    • 01112017-cleanup
    • None
    • manual

    Description

      Currently we cover off a few finite examples of how to build indexes for certain kinds of queries. Support regularly recommend reading the following blog post by Jesse to many of our customers as it contains some stellar thinking and a great methodology:
      http://emptysqua.re/blog/optimizing-mongodb-compound-indexes/#method

      Can we add a new document which explains how to think about building indexes for particular families of queries and (assuming Jesse is okay with it) provides his suggested method for thinking about indexes:

      1. Equality Tests
        1. Add all equality-tested fields to the compound index, in any order
      2. Sort Fields (ascending / descending only matters if there are multiple sort fields)
        1. Add sort fields to the index in the same order and direction as your query's sort
      3. Range Filters
        1. First, add the range filter for the field with the lowest cardinality (fewest distinct values in the collection)
        2. Then the next lowest-cardinality range filter, and so on to the highest-cardinality

      Attachments

        Activity

          People

            Unassigned Unassigned
            david.hows David Hows
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              7 years, 29 weeks ago