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

Record does not seem to be indexed correctly

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.2.2
    • Component/s: Shell
    • None
    • ALL
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None

      I have a record in my database but it doesn't seem to be indexed correctly.
      I have a compound index
      {
      "v" : 1,
      "key" :

      { "device" : 1, "time" : -1 }

      ,
      "ns" : "loco.history",
      "name" : "device_1_time_-1"
      },

      and this is used to run the query.

      locobase:SECONDARY> db.history.find({device:357207050859404,"time":{"$gt":start,"$lt":end}}).explain()
      {
      "cursor" : "BtreeCursor device_1_time_-1",
      "isMultiKey" : false,
      "n" : 19,
      "nscannedObjects" : 19,
      "nscanned" : 19,
      "nscannedObjectsAllPlans" : 19,
      "nscannedAllPlans" : 19,
      "scanAndOrder" : false,
      "indexOnly" : false,
      "nYields" : 0,
      "nChunkSkips" : 0,
      "millis" : 0,
      "indexBounds" :

      { "device" : [ [ 357207050859404, 357207050859404 ] ], "time" : [ [ ISODate("2015-04-01T00:00:00Z"), ISODate("2010-04-01T00:00:00Z") ] ] }

      ,
      "server" : "uk4.loco-pos.net:27017"
      }

      note: there are 19 items found

      but if I give a hint to not use the time field in the index I get

      locobase:SECONDARY> db.history.find({device:357207050859404,"time":{"$gt":start,"$lt":end}}).hint(

      {device:1}

      ).explain()
      {
      "cursor" : "BtreeCursor device_1",
      "isMultiKey" : false,
      "n" : 19,
      "nscannedObjects" : 20,
      "nscanned" : 20,
      "nscannedObjectsAllPlans" : 20,
      "nscannedAllPlans" : 20,
      "scanAndOrder" : false,
      "indexOnly" : false,
      "nYields" : 0,
      "nChunkSkips" : 0,
      "millis" : 0,
      "indexBounds" :

      { "device" : [ [ 357207050859404, 357207050859404 ] ] }

      ,
      "server" : "uk4.loco-pos.net:27017"
      }

      now there are 20 items.

      The missing item has
      locobase:SECONDARY> db.history.findOne({_id:ObjectId("533a8bf3d6e909b3c29e6e38")}).time
      ISODate("2014-04-01T09:50:43.487Z")

      as far as I know, There are no other records with this problem and everything else seems normal.
      I realise 2.2.2 is quite old but this may still be relevant.

            Assignee:
            Unassigned Unassigned
            Reporter:
            ianmartin Ian Martin
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: