Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-4408

_id index should be used for find queries against nested fields of the _id object

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 2.0.1
    • Component/s: Querying
    • Labels:
      None
    • Query Optimization

      > db.textarea.vermongo.find();
      { "_id" : { "_id" : "y", "_version" : 1 }, "name" : "Thilo Planz", "_version" : 1 }
      
      > db.textarea.vermongo.find( {'_id': {'_id': 'y', '_version': 1 }});
      { "_id" : { "_id" : "y", "_version" : 1 }, "name" : "Thilo Planz", "_version" : 1 }
      
      explain =>
      	"cursor" : "BtreeCursor _id_",
      
      > db.textarea.vermongo.find( {'_id._id': 'y'});
      
      explain =>
             "cursor" : "BasicCursor",
      

      When using a BSONObject as the _id for the record, querying against only a part of the object should still use the _id btree index. I appreciate that because the existence and order of fields in the nested document is not known, this will not be a range scan (not even for an _id field of the nested document), but a "fast-full-index-scan" type of access path should be possible and faster than a table scan.

            Assignee:
            backlog-query-optimization [DO NOT USE] Backlog - Query Optimization
            Reporter:
            thiloplanz Thilo Planz
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated: