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

Wrong index is being picked

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.6.1
    • Component/s: Querying
    • None
    • ALL

      Hi guys,

      We have a weird issue with MongoDB 2.6.0/2.6.1 picking a wrong index.

      So we have a really huge collection (~250MM docs) with the following indexes defined:

      [
      	{
      		"_id" : 1
      	},
      	{
      		"mid" : 1,
      		"r1" : -1
      	},
      	{
      		"mid" : 1,
      		"r2" : -1
      	},
      	{
      		"key" : 1
      	},
      	{
      		"mid" : 1,
      		"key" : 1
      	},
      	{
      		"mid" : 1
      	}
      ]
      

      Yet, sometimes, under a heavy load, the database starts freaking out - consumes >1000% CPU, performance degrades dramatically and I see the following entries in the logs:

      2014-05-07T15:54:30.587+0000 [conn153098] query <collection>: { mid: ObjectId('4fa0d0914711596b17039e29'), key: "liuruile@163.com" } planSummary: IXSCAN { mid: 1, r1: -1 } ntoskip:0 nscanned:731072 nscannedObjects:731071 keyUpdates:0 numYields:6048 locks(micros) r:181118904 nreturned:1 reslen:214 486438ms
      

      As you can see the wrong index is being picked. In fact, I see the same behavior for a lot of other collections as well. It looks like the very first index (after _id) is being picked all the time.

      Do you have any idea on what might be causing this?

            Assignee:
            Unassigned Unassigned
            Reporter:
            r0mant Roman Tkachenko
            Votes:
            1 Vote for this issue
            Watchers:
            12 Start watching this issue

              Created:
              Updated:
              Resolved: