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

How to optimize the query

    • Type: Icon: Question Question
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Querying
    • Labels:
      None
    • Environment:
      Linux

      I have a capped collection with 1.3 million documents indexed on id.
      When i do a query with a filter it takes more than 1 minute to give back the result. The query includes find with sort on id and limit(20).
      I need to get back the query result in max 30-45 seconds.
      Let me know what enhancements can be done.
      Below is explain output from shell. Same query i use from perl driver

      {
      	"cursor" : "BtreeCursor _id_ reverse",
      	"isMultiKey" : false,
      	"n" : 0,
      	"nscannedObjects" : 1308194,
      	"nscanned" : 1308194,
      	"nscannedObjectsAllPlans" : 2616388,
      	"nscannedAllPlans" : 2616388,
      	"scanAndOrder" : false,
      	"indexOnly" : false,
      	"nYields" : 72,
      	"nChunkSkips" : 0,
      	"millis" : 109349,
      	"indexBounds" : {
      		"_id" : [
      			[
      				{
      					"$maxElement" : 1
      				},
      				{
      					"$minElement" : 1
      				}
      			]
      		]
      	},
      

      Thanks

            Assignee:
            Unassigned Unassigned
            Reporter:
            asethy Arati Sethy
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: