Internally sort criteria and index fields?

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Won't Fix
    • Priority: Major - P3
    • 12_01_17
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Hello

      As the order of criteria fields matters: http://docs.mongodb.org/manual/core/index-compound/#prefixes

      I was wondering why not always sort the fields by key_name before creating indexes and searching?

      i.e.

      db.my_collection.ensure_index(b: 1, c: 1, a: 1)
      => internally could be replaced by db.my_collection.ensure_index(a: 1, b: 1, c: 1)

      db.my_collection.find(c: 'c', b: 'b', a: 'a')
      => internally could be replaced by db.my_collection.find(a: 'a', b: 'b', c: 'c')

      I think it could help to match the indexes easier, especially in cases we add the criteria fields based on user filter selections (complex views).

      Does that make sense?

      Thanks

            Assignee:
            Unassigned
            Reporter:
            Pablo Cantero
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: