-
Type: Bug
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: 3.2.6
-
Component/s: Querying
-
None
I have a collection "activities2":
Index
{ action: 1, userId: 1, time: 1 }
I run a query:
Query
db.activities2.find({ userId: { $in: [ ObjectId("5373bcfef88919d05eee3149"), ObjectId("537468fff88919d05eee322c"), ObjectId("537f543778f03be40e598ade"), ObjectId("5382f987832983fb3a5ae9d4"), ObjectId("53a561b2663e61b528241bc4"), ObjectId("53a80878cde71b653ed82539"), ObjectId("53a8cc6511b9cc964959c365"), ObjectId("53acbfb3cb9f89250d02c48a"), ObjectId("53af045ebcc79931692a4aa7"), ObjectId("53b494fb9809bceb3fd25c89"), ObjectId("53b6eae20c4a07fe63db10b3"), ObjectId("53b831b49809bceb3fd2cfab"), ObjectId("53bab1e2b5067de0061a4567"), ObjectId("53bb05e1386b18ce5b20d86b"), ] }, action: { $in: [ "ANSAttempt", "GooglePlusAttempt", "TwitterAttempt", "articleLike", "articleShare", "fbMessengerAttempt", "fbShare", "follow", "forumComment_add", "forumPost_add", "forumPost_edit", "like", "objectLike_forumComment", "objectLike_forumPost", "objectLike_userProfileImage", "objectLike_userUpdatedTagline", "objectShare_forumComment", "objectShare_forumPost", "share", "signin", "userUpdatedPicture", "userUpdatedTagline" ] }, time: { "$lt" : toDate, // "$gte": fromDate, } }, { action: 1, userId: 1, time: 1, _id: 0, }) .sort({ time: -1 }) .limit(100) .hint({ action: 1, userId: 1, time: 1, }) .explain(1)
Partial explain result:
Explain
{ "executionSuccess" : true, "nReturned" : NumberInt(100), "executionTimeMillis" : NumberInt(10), "totalKeysExamined" : NumberInt(2210), "totalDocsExamined" : NumberInt(2210), "executionStages" : { "stage" : "PROJECTION", "nReturned" : NumberInt(100), "executionTimeMillisEstimate" : NumberInt(10), "works" : NumberInt(2313), "advanced" : NumberInt(100), "needTime" : NumberInt(2212), "needYield" : NumberInt(0), "saveState" : NumberInt(18), "restoreState" : NumberInt(18), "isEOF" : NumberInt(1), "invalidates" : NumberInt(0), "transformBy" : { "action" : NumberInt(1), "userId" : NumberInt(1), "time" : NumberInt(1), "_id" : NumberInt(0) }, "inputStage" : { "stage" : "SORT", "nReturned" : NumberInt(100), "executionTimeMillisEstimate" : NumberInt(10), "works" : NumberInt(2313), "advanced" : NumberInt(100), "needTime" : NumberInt(2212), "needYield" : NumberInt(0), "saveState" : NumberInt(18), "restoreState" : NumberInt(18), "isEOF" : NumberInt(1), "invalidates" : NumberInt(0), "sortPattern" : { "time" : NumberInt(-1) }, "memUsage" : NumberInt(9432), "memLimit" : NumberInt(33554432), "limitAmount" : NumberInt(100), "inputStage" : { "stage" : "SORT_KEY_GENERATOR", "nReturned" : NumberInt(0), "executionTimeMillisEstimate" : NumberInt(10), "works" : NumberInt(2212), "advanced" : NumberInt(0), "needTime" : NumberInt(1), "needYield" : NumberInt(0), "saveState" : NumberInt(18), "restoreState" : NumberInt(18), "isEOF" : NumberInt(1), "invalidates" : NumberInt(0), "inputStage" : { "stage" : "FETCH", "nReturned" : NumberInt(2210), "executionTimeMillisEstimate" : NumberInt(10), "works" : NumberInt(2211), "advanced" : NumberInt(2210), "needTime" : NumberInt(0), "needYield" : NumberInt(0), "saveState" : NumberInt(18), "restoreState" : NumberInt(18), "isEOF" : NumberInt(1), "invalidates" : NumberInt(0), "docsExamined" : NumberInt(2210), "alreadyHasObj" : NumberInt(0), "inputStage" : { "stage" : "IXSCAN", "nReturned" : NumberInt(2210), "executionTimeMillisEstimate" : NumberInt(10), "works" : NumberInt(2211), "advanced" : NumberInt(2210), "needTime" : NumberInt(0), "needYield" : NumberInt(0), "saveState" : NumberInt(18), "restoreState" : NumberInt(18), "isEOF" : NumberInt(1), "invalidates" : NumberInt(0), "keyPattern" : { "action" : NumberInt(1), "userId" : NumberInt(1), "time" : NumberInt(1) }, "indexName" : "action_1_userId_1_time_1", "isMultiKey" : false, "isUnique" : false, "isSparse" : false, "isPartial" : false, "indexVersion" : NumberInt(1), "direction" : "backward", "indexBounds" : { "action" : [ "[\"userUpdatedTagline\", \"userUpdatedTagline\"]", "[\"userUpdatedPicture\", \"userUpdatedPicture\"]", "[\"signin\", \"signin\"]", "[\"share\", \"share\"]", "[\"objectShare_forumPost\", \"objectShare_forumPost\"]", "[\"objectShare_forumComment\", \"objectShare_forumComment\"]", "[\"objectLike_userUpdatedTagline\", \"objectLike_userUpdatedTagline\"]", "[\"objectLike_userProfileImage\", \"objectLike_userProfileImage\"]", "[\"objectLike_forumPost\", \"objectLike_forumPost\"]", "[\"objectLike_forumComment\", \"objectLike_forumComment\"]", "[\"like\", \"like\"]", "[\"forumPost_edit\", \"forumPost_edit\"]", "[\"forumPost_add\", \"forumPost_add\"]", "[\"forumComment_add\", \"forumComment_add\"]", "[\"follow\", \"follow\"]", "[\"fbShare\", \"fbShare\"]", "[\"fbMessengerAttempt\", \"fbMessengerAttempt\"]", "[\"articleShare\", \"articleShare\"]", "[\"articleLike\", \"articleLike\"]", "[\"TwitterAttempt\", \"TwitterAttempt\"]", "[\"GooglePlusAttempt\", \"GooglePlusAttempt\"]", "[\"ANSAttempt\", \"ANSAttempt\"]" ], "userId" : [ "[ObjectId('53bb05e1386b18ce5b20d86b'), ObjectId('53bb05e1386b18ce5b20d86b')]", "[ObjectId('53bab1e2b5067de0061a4567'), ObjectId('53bab1e2b5067de0061a4567')]", "[ObjectId('53b831b49809bceb3fd2cfab'), ObjectId('53b831b49809bceb3fd2cfab')]", "[ObjectId('53b6eae20c4a07fe63db10b3'), ObjectId('53b6eae20c4a07fe63db10b3')]", "[ObjectId('53b494fb9809bceb3fd25c89'), ObjectId('53b494fb9809bceb3fd25c89')]", "[ObjectId('53af045ebcc79931692a4aa7'), ObjectId('53af045ebcc79931692a4aa7')]", "[ObjectId('53acbfb3cb9f89250d02c48a'), ObjectId('53acbfb3cb9f89250d02c48a')]", "[ObjectId('53a8cc6511b9cc964959c365'), ObjectId('53a8cc6511b9cc964959c365')]", "[ObjectId('53a80878cde71b653ed82539'), ObjectId('53a80878cde71b653ed82539')]", "[ObjectId('53a561b2663e61b528241bc4'), ObjectId('53a561b2663e61b528241bc4')]", "[ObjectId('5382f987832983fb3a5ae9d4'), ObjectId('5382f987832983fb3a5ae9d4')]", "[ObjectId('537f543778f03be40e598ade'), ObjectId('537f543778f03be40e598ade')]", "[ObjectId('537468fff88919d05eee322c'), ObjectId('537468fff88919d05eee322c')]", "[ObjectId('5373bcfef88919d05eee3149'), ObjectId('5373bcfef88919d05eee3149')]" ], "time" : [ "(new Date(1461292516649), true)" ] }, "keysExamined" : NumberInt(2210), "dupsTested" : NumberInt(0), "dupsDropped" : NumberInt(0), "seenInvalidated" : NumberInt(0) } } } } }, "allPlansExecution" : [ ] }
A collection data is attached.
- duplicates
-
SERVER-15221 Planner sort analysis should not add FETCH stage if sort key included in index key pattern
- Closed