[SERVER-35456]  Incorrect result when using regexp in $in Created: 06/Jun/18  Updated: 04/Nov/18  Resolved: 01/Oct/18

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Suguru Namura Assignee: Nick Brewer
Resolution: Incomplete Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Participants:

 Description   

Hi,

I am operating a 6 shard MongoDB Cluster.
The following two patterns of queries should have the same results, but sometimes they are incorrect.

mongos> db.programs.find({ _id: /hoge/ }).count()
0

mongos> db.programs.find({_id: {$in: [/hoge/] }}).count()
51

However in explain("executionStats") results both nReturned is 51.
Also, even I execute the same query on each shard node, each result is different.

What kind of cause can be considered?



 Comments   
Comment by Nick Brewer [ 01/Oct/18 ]

service@abema.tv Since there's been no activity on this ticket in some time, I'm going to close it. Feel free to update this ticket with the requested information, and we'll reopen it for you.

Thanks,
-Nick

Comment by Nick Brewer [ 14/Sep/18 ]

service@abema.tv Are you still seeing this issue? If so, we'll need the planCacheListPlans output to identify if the mismatched results are due to a cached plan.

Thanks,
-Nick

Comment by Nick Brewer [ 19/Jul/18 ]

service@abema.tv Sorry for the delay in getting back to you. I'd like to rule out the possibility that the difference is results is due to a cached plan. Could you please provide planCacheListPlans output for both of the commands? You can upload them to the secure portal.

Thanks,
Nick

Comment by Suguru Namura [ 25/Jun/18 ]

Hi,

I appreciate your support.
uploaded the results of the correct query to secure upload portal.

> I'd like to confirm that both of these queries are always being run from the same database
I think that you can see that it is executing with the same database in the result file.

Thanks

Comment by Nick Brewer [ 20/Jun/18 ]

Hi,

To get a better understanding of the problem, we'll need to see the actual queries that are being run, without the values changed. Specifically, the output of:

db.COLLECTION.explain(true).find({ _id: /REGEX/ }).count()
db.COLLECTION.explain(true).find({_id: {$in: [/REGEX/] }}).count()
db.COLLECTION.find({ _id: /REGEX/ })
db.COLLECTION.find({_id: {$in: [/REGEX/] }})

The COLLECTION and REGEX placeholders should be substituted for the actual values that you're using in your queries; these queries should be an exact match for those that you're using in production when you encounter this issue. You can upload the results to our secure upload portal. Information stored on this page is only available to MongoDB employees, and it is removed after a period of time.

Finally, I'd like to confirm that both of these queries are always being run from the same database - in many instances where two identical queries against a collection return such different values (51 as opposed to 0), it is because the query that returns "0" is being run from the wrong database.

Thanks,
Nick

Comment by Suguru Namura [ 07/Jun/18 ]

mongos> db.programs.find({_id: {$in: [/hoge/] }}).explain(true)
{
	"queryPlanner" : {
		"mongosPlannerVersion" : 1,
		"winningPlan" : {
			"stage" : "SHARD_MERGE",
			"shards" : [
				{
					"shardName" : "production_0",
					"connectionString" : "production_0/prd-mongod-01-a.c.formidable-byte-89507.internal:27000,prd-mongod-01-b.c.formidable-byte-89507.internal:27000,prd-mongod-01-c.c.formidable-byte-89507.internal:27000,prd-mongod-04-a.c.formidable-byte-89507.internal:27000,prd-mongod-05-b.c.formidable-byte-89507.internal:27000,prd-mongod-06-c.c.formidable-byte-89507.internal:27000,prd-mongod-15-b.c.formidable-byte-89507.internal:27000,prd-mongod-15-c.c.formidable-byte-89507.internal:27000",
					"serverInfo" : {
						"host" : "prd-mongod-01-a",
						"port" : 27000,
						"version" : "3.2.16",
						"gitVersion" : "056bf45128114e44c5358c7a8776fb582363e094"
					},
					"plannerVersion" : 1,
					"namespace" : "dbname.programs",
					"indexFilterSet" : false,
					"parsedQuery" : {
						"_id" : {
							"$in" : [
								/hoge/
							]
						}
					},
					"winningPlan" : {
						"stage" : "FETCH",
						"inputStage" : {
							"stage" : "SHARDING_FILTER",
							"inputStage" : {
								"stage" : "IXSCAN",
								"filter" : {
									"_id" : {
										"$in" : [
											/hoge/
										]
									}
								},
								"keyPattern" : {
									"_id" : 1
								},
								"indexName" : "_id_",
								"isMultiKey" : false,
								"isUnique" : true,
								"isSparse" : false,
								"isPartial" : false,
								"indexVersion" : 1,
								"direction" : "forward",
								"indexBounds" : {
									"_id" : [
										"[\"\", {})",
										"[/hoge/, /hoge/]"
									]
								}
							}
						}
					},
					"rejectedPlans" : [ ]
				},
				{
					"shardName" : "production_1",
					"connectionString" : "production_1/prd-mongod-02-a.c.formidable-byte-89507.internal:27000,prd-mongod-02-b.c.formidable-byte-89507.internal:27000,prd-mongod-02-c.c.formidable-byte-89507.internal:27000,prd-mongod-04-b.c.formidable-byte-89507.internal:27000,prd-mongod-05-c.c.formidable-byte-89507.internal:27000,prd-mongod-06-a.c.formidable-byte-89507.internal:27000,prd-mongod-13-a.c.formidable-byte-89507.internal:27000,prd-mongod-13-b.c.formidable-byte-89507.internal:27000,prd-mongod-13-c.c.formidable-byte-89507.internal:27000,prd-mongod-14-a.c.formidable-byte-89507.internal:27000,prd-mongod-14-b.c.formidable-byte-89507.internal:27000,prd-mongod-14-c.c.formidable-byte-89507.internal:27000,prd-mongod-17-a.c.formidable-byte-89507.internal:27000,prd-mongod-17-b.c.formidable-byte-89507.internal:27000,prd-mongod-17-c.c.formidable-byte-89507.internal:27000",
					"serverInfo" : {
						"host" : "prd-mongod-02-a",
						"port" : 27000,
						"version" : "3.2.16",
						"gitVersion" : "056bf45128114e44c5358c7a8776fb582363e094"
					},
					"plannerVersion" : 1,
					"namespace" : "dbname.programs",
					"indexFilterSet" : false,
					"parsedQuery" : {
						"_id" : {
							"$in" : [
								/hoge/
							]
						}
					},
					"winningPlan" : {
						"stage" : "FETCH",
						"inputStage" : {
							"stage" : "SHARDING_FILTER",
							"inputStage" : {
								"stage" : "IXSCAN",
								"filter" : {
									"_id" : {
										"$in" : [
											/hoge/
										]
									}
								},
								"keyPattern" : {
									"_id" : 1
								},
								"indexName" : "_id_",
								"isMultiKey" : false,
								"isUnique" : true,
								"isSparse" : false,
								"isPartial" : false,
								"indexVersion" : 1,
								"direction" : "forward",
								"indexBounds" : {
									"_id" : [
										"[\"\", {})",
										"[/hoge/, /hoge/]"
									]
								}
							}
						}
					},
					"rejectedPlans" : [ ]
				},
				{
					"shardName" : "production_2",
					"connectionString" : "production_2/prd-mongod-03-a.c.formidable-byte-89507.internal:27000,prd-mongod-03-b.c.formidable-byte-89507.internal:27000,prd-mongod-03-c.c.formidable-byte-89507.internal:27000,prd-mongod-04-c.c.formidable-byte-89507.internal:27000,prd-mongod-05-a.c.formidable-byte-89507.internal:27000,prd-mongod-06-b.c.formidable-byte-89507.internal:27000,prd-mongod-18-b.c.formidable-byte-89507.internal:27000,prd-mongod-18-c.c.formidable-byte-89507.internal:27000,prd-mongod-19-a.c.formidable-byte-89507.internal:27000",
					"serverInfo" : {
						"host" : "prd-mongod-03-b",
						"port" : 27000,
						"version" : "3.2.16",
						"gitVersion" : "056bf45128114e44c5358c7a8776fb582363e094"
					},
					"plannerVersion" : 1,
					"namespace" : "dbname.programs",
					"indexFilterSet" : false,
					"parsedQuery" : {
						"_id" : {
							"$in" : [
								/hoge/
							]
						}
					},
					"winningPlan" : {
						"stage" : "FETCH",
						"inputStage" : {
							"stage" : "SHARDING_FILTER",
							"inputStage" : {
								"stage" : "IXSCAN",
								"filter" : {
									"_id" : {
										"$in" : [
											/hoge/
										]
									}
								},
								"keyPattern" : {
									"_id" : 1
								},
								"indexName" : "_id_",
								"isMultiKey" : false,
								"isUnique" : true,
								"isSparse" : false,
								"isPartial" : false,
								"indexVersion" : 1,
								"direction" : "forward",
								"indexBounds" : {
									"_id" : [
										"[\"\", {})",
										"[/hoge/, /hoge/]"
									]
								}
							}
						}
					},
					"rejectedPlans" : [ ]
				},
				{
					"shardName" : "production_3",
					"connectionString" : "production_3/prd-mongod-07-a.c.formidable-byte-89507.internal:27000,prd-mongod-07-b.c.formidable-byte-89507.internal:27000,prd-mongod-07-c.c.formidable-byte-89507.internal:27000,prd-mongod-10-a.c.formidable-byte-89507.internal:27000,prd-mongod-11-b.c.formidable-byte-89507.internal:27000,prd-mongod-12-c.c.formidable-byte-89507.internal:27000,prd-mongod-20-a.c.formidable-byte-89507.internal:27000,prd-mongod-20-b.c.formidable-byte-89507.internal:27000,prd-mongod-20-c.c.formidable-byte-89507.internal:27000",
					"serverInfo" : {
						"host" : "prd-mongod-07-b",
						"port" : 27000,
						"version" : "3.2.16",
						"gitVersion" : "056bf45128114e44c5358c7a8776fb582363e094"
					},
					"plannerVersion" : 1,
					"namespace" : "dbname.programs",
					"indexFilterSet" : false,
					"parsedQuery" : {
						"_id" : {
							"$in" : [
								/hoge/
							]
						}
					},
					"winningPlan" : {
						"stage" : "FETCH",
						"inputStage" : {
							"stage" : "SHARDING_FILTER",
							"inputStage" : {
								"stage" : "IXSCAN",
								"filter" : {
									"_id" : {
										"$in" : [
											/hoge/
										]
									}
								},
								"keyPattern" : {
									"_id" : 1
								},
								"indexName" : "_id_",
								"isMultiKey" : false,
								"isUnique" : true,
								"isSparse" : false,
								"isPartial" : false,
								"indexVersion" : 1,
								"direction" : "forward",
								"indexBounds" : {
									"_id" : [
										"[\"\", {})",
										"[/hoge/, /hoge/]"
									]
								}
							}
						}
					},
					"rejectedPlans" : [ ]
				},
				{
					"shardName" : "production_4",
					"connectionString" : "production_4/prd-mongod-08-a.c.formidable-byte-89507.internal:27000,prd-mongod-08-b.c.formidable-byte-89507.internal:27000,prd-mongod-08-c.c.formidable-byte-89507.internal:27000,prd-mongod-10-b.c.formidable-byte-89507.internal:27000,prd-mongod-11-c.c.formidable-byte-89507.internal:27000,prd-mongod-12-a.c.formidable-byte-89507.internal:27000,prd-mongod-22-a.c.formidable-byte-89507.internal:27000,prd-mongod-22-b.c.formidable-byte-89507.internal:27000,prd-mongod-22-c.c.formidable-byte-89507.internal:27000",
					"serverInfo" : {
						"host" : "prd-mongod-11-c",
						"port" : 27000,
						"version" : "3.2.16",
						"gitVersion" : "056bf45128114e44c5358c7a8776fb582363e094"
					},
					"plannerVersion" : 1,
					"namespace" : "dbname.programs",
					"indexFilterSet" : false,
					"parsedQuery" : {
						"_id" : {
							"$in" : [
								/hoge/
							]
						}
					},
					"winningPlan" : {
						"stage" : "FETCH",
						"inputStage" : {
							"stage" : "SHARDING_FILTER",
							"inputStage" : {
								"stage" : "IXSCAN",
								"filter" : {
									"_id" : {
										"$in" : [
											/hoge/
										]
									}
								},
								"keyPattern" : {
									"_id" : 1
								},
								"indexName" : "_id_",
								"isMultiKey" : false,
								"isUnique" : true,
								"isSparse" : false,
								"isPartial" : false,
								"indexVersion" : 1,
								"direction" : "forward",
								"indexBounds" : {
									"_id" : [
										"[\"\", {})",
										"[/hoge/, /hoge/]"
									]
								}
							}
						}
					},
					"rejectedPlans" : [ ]
				},
				{
					"shardName" : "production_5",
					"connectionString" : "production_5/prd-mongod-09-a.c.formidable-byte-89507.internal:27000,prd-mongod-09-b.c.formidable-byte-89507.internal:27000,prd-mongod-09-c.c.formidable-byte-89507.internal:27000,prd-mongod-10-c.c.formidable-byte-89507.internal:27000,prd-mongod-11-a.c.formidable-byte-89507.internal:27000,prd-mongod-12-b.c.formidable-byte-89507.internal:27000,prd-mongod-23-c.c.formidable-byte-89507.internal:27000,prd-mongod-24-a.c.formidable-byte-89507.internal:27000",
					"serverInfo" : {
						"host" : "prd-mongod-11-a",
						"port" : 27000,
						"version" : "3.2.16",
						"gitVersion" : "056bf45128114e44c5358c7a8776fb582363e094"
					},
					"plannerVersion" : 1,
					"namespace" : "dbname.programs",
					"indexFilterSet" : false,
					"parsedQuery" : {
						"_id" : {
							"$in" : [
								/hoge/
							]
						}
					},
					"winningPlan" : {
						"stage" : "FETCH",
						"inputStage" : {
							"stage" : "SHARDING_FILTER",
							"inputStage" : {
								"stage" : "IXSCAN",
								"filter" : {
									"_id" : {
										"$in" : [
											/hoge/
										]
									}
								},
								"keyPattern" : {
									"_id" : 1
								},
								"indexName" : "_id_",
								"isMultiKey" : false,
								"isUnique" : true,
								"isSparse" : false,
								"isPartial" : false,
								"indexVersion" : 1,
								"direction" : "forward",
								"indexBounds" : {
									"_id" : [
										"[\"\", {})",
										"[/hoge/, /hoge/]"
									]
								}
							}
						}
					},
					"rejectedPlans" : [ ]
				}
			]
		}
	},
	"executionStats" : {
		"nReturned" : 51,
		"executionTimeMillis" : 53,
		"totalKeysExamined" : 122568,
		"totalDocsExamined" : 51,
		"executionStages" : {
			"stage" : "SHARD_MERGE",
			"nReturned" : 51,
			"executionTimeMillis" : 53,
			"totalKeysExamined" : 122568,
			"totalDocsExamined" : 51,
			"totalChildMillis" : NumberLong(212),
			"shards" : [
				{
					"shardName" : "production_0",
					"executionSuccess" : true,
					"executionStages" : {
						"stage" : "FETCH",
						"nReturned" : 8,
						"executionTimeMillisEstimate" : 20,
						"works" : 22226,
						"advanced" : 8,
						"needTime" : 22217,
						"needYield" : 0,
						"saveState" : 173,
						"restoreState" : 173,
						"isEOF" : 1,
						"invalidates" : 0,
						"docsExamined" : 8,
						"alreadyHasObj" : 0,
						"inputStage" : {
							"stage" : "SHARDING_FILTER",
							"nReturned" : 8,
							"executionTimeMillisEstimate" : 20,
							"works" : 22226,
							"advanced" : 8,
							"needTime" : 22217,
							"needYield" : 0,
							"saveState" : 173,
							"restoreState" : 173,
							"isEOF" : 1,
							"invalidates" : 0,
							"chunkSkips" : 0,
							"inputStage" : {
								"stage" : "IXSCAN",
								"filter" : {
									"_id" : {
										"$in" : [
											/hoge/
										]
									}
								},
								"nReturned" : 8,
								"executionTimeMillisEstimate" : 20,
								"works" : 22226,
								"advanced" : 8,
								"needTime" : 22217,
								"needYield" : 0,
								"saveState" : 173,
								"restoreState" : 173,
								"isEOF" : 1,
								"invalidates" : 0,
								"keyPattern" : {
									"_id" : 1
								},
								"indexName" : "_id_",
								"isMultiKey" : false,
								"isUnique" : true,
								"isSparse" : false,
								"isPartial" : false,
								"indexVersion" : 1,
								"direction" : "forward",
								"indexBounds" : {
									"_id" : [
										"[\"\", {})",
										"[/hoge/, /hoge/]"
									]
								},
								"keysExamined" : 22225,
								"dupsTested" : 0,
								"dupsDropped" : 0,
								"seenInvalidated" : 0
							}
						}
					}
				},
				{
					"shardName" : "production_1",
					"executionSuccess" : true,
					"executionStages" : {
						"stage" : "FETCH",
						"nReturned" : 6,
						"executionTimeMillisEstimate" : 30,
						"works" : 19419,
						"advanced" : 6,
						"needTime" : 19412,
						"needYield" : 0,
						"saveState" : 151,
						"restoreState" : 151,
						"isEOF" : 1,
						"invalidates" : 0,
						"docsExamined" : 6,
						"alreadyHasObj" : 0,
						"inputStage" : {
							"stage" : "SHARDING_FILTER",
							"nReturned" : 6,
							"executionTimeMillisEstimate" : 30,
							"works" : 19419,
							"advanced" : 6,
							"needTime" : 19412,
							"needYield" : 0,
							"saveState" : 151,
							"restoreState" : 151,
							"isEOF" : 1,
							"invalidates" : 0,
							"chunkSkips" : 0,
							"inputStage" : {
								"stage" : "IXSCAN",
								"filter" : {
									"_id" : {
										"$in" : [
											/hoge/
										]
									}
								},
								"nReturned" : 6,
								"executionTimeMillisEstimate" : 30,
								"works" : 19419,
								"advanced" : 6,
								"needTime" : 19412,
								"needYield" : 0,
								"saveState" : 151,
								"restoreState" : 151,
								"isEOF" : 1,
								"invalidates" : 0,
								"keyPattern" : {
									"_id" : 1
								},
								"indexName" : "_id_",
								"isMultiKey" : false,
								"isUnique" : true,
								"isSparse" : false,
								"isPartial" : false,
								"indexVersion" : 1,
								"direction" : "forward",
								"indexBounds" : {
									"_id" : [
										"[\"\", {})",
										"[/hoge/, /hoge/]"
									]
								},
								"keysExamined" : 19418,
								"dupsTested" : 0,
								"dupsDropped" : 0,
								"seenInvalidated" : 0
							}
						}
					}
				},
				{
					"shardName" : "production_2",
					"executionSuccess" : true,
					"executionStages" : {
						"stage" : "FETCH",
						"nReturned" : 7,
						"executionTimeMillisEstimate" : 50,
						"works" : 19113,
						"advanced" : 7,
						"needTime" : 19105,
						"needYield" : 0,
						"saveState" : 149,
						"restoreState" : 149,
						"isEOF" : 1,
						"invalidates" : 0,
						"docsExamined" : 7,
						"alreadyHasObj" : 0,
						"inputStage" : {
							"stage" : "SHARDING_FILTER",
							"nReturned" : 7,
							"executionTimeMillisEstimate" : 50,
							"works" : 19113,
							"advanced" : 7,
							"needTime" : 19105,
							"needYield" : 0,
							"saveState" : 149,
							"restoreState" : 149,
							"isEOF" : 1,
							"invalidates" : 0,
							"chunkSkips" : 0,
							"inputStage" : {
								"stage" : "IXSCAN",
								"filter" : {
									"_id" : {
										"$in" : [
											/hoge/
										]
									}
								},
								"nReturned" : 7,
								"executionTimeMillisEstimate" : 50,
								"works" : 19113,
								"advanced" : 7,
								"needTime" : 19105,
								"needYield" : 0,
								"saveState" : 149,
								"restoreState" : 149,
								"isEOF" : 1,
								"invalidates" : 0,
								"keyPattern" : {
									"_id" : 1
								},
								"indexName" : "_id_",
								"isMultiKey" : false,
								"isUnique" : true,
								"isSparse" : false,
								"isPartial" : false,
								"indexVersion" : 1,
								"direction" : "forward",
								"indexBounds" : {
									"_id" : [
										"[\"\", {})",
										"[/hoge/, /hoge/]"
									]
								},
								"keysExamined" : 19112,
								"dupsTested" : 0,
								"dupsDropped" : 0,
								"seenInvalidated" : 0
							}
						}
					}
				},
				{
					"shardName" : "production_3",
					"executionSuccess" : true,
					"executionStages" : {
						"stage" : "FETCH",
						"nReturned" : 13,
						"executionTimeMillisEstimate" : 50,
						"works" : 19302,
						"advanced" : 13,
						"needTime" : 19288,
						"needYield" : 0,
						"saveState" : 150,
						"restoreState" : 150,
						"isEOF" : 1,
						"invalidates" : 0,
						"docsExamined" : 13,
						"alreadyHasObj" : 0,
						"inputStage" : {
							"stage" : "SHARDING_FILTER",
							"nReturned" : 13,
							"executionTimeMillisEstimate" : 50,
							"works" : 19302,
							"advanced" : 13,
							"needTime" : 19288,
							"needYield" : 0,
							"saveState" : 150,
							"restoreState" : 150,
							"isEOF" : 1,
							"invalidates" : 0,
							"chunkSkips" : 0,
							"inputStage" : {
								"stage" : "IXSCAN",
								"filter" : {
									"_id" : {
										"$in" : [
											/hoge/
										]
									}
								},
								"nReturned" : 13,
								"executionTimeMillisEstimate" : 50,
								"works" : 19302,
								"advanced" : 13,
								"needTime" : 19288,
								"needYield" : 0,
								"saveState" : 150,
								"restoreState" : 150,
								"isEOF" : 1,
								"invalidates" : 0,
								"keyPattern" : {
									"_id" : 1
								},
								"indexName" : "_id_",
								"isMultiKey" : false,
								"isUnique" : true,
								"isSparse" : false,
								"isPartial" : false,
								"indexVersion" : 1,
								"direction" : "forward",
								"indexBounds" : {
									"_id" : [
										"[\"\", {})",
										"[/hoge/, /hoge/]"
									]
								},
								"keysExamined" : 19301,
								"dupsTested" : 0,
								"dupsDropped" : 0,
								"seenInvalidated" : 0
							}
						}
					}
				},
				{
					"shardName" : "production_4",
					"executionSuccess" : true,
					"executionStages" : {
						"stage" : "FETCH",
						"nReturned" : 10,
						"executionTimeMillisEstimate" : 10,
						"works" : 21266,
						"advanced" : 10,
						"needTime" : 21255,
						"needYield" : 0,
						"saveState" : 166,
						"restoreState" : 166,
						"isEOF" : 1,
						"invalidates" : 0,
						"docsExamined" : 10,
						"alreadyHasObj" : 0,
						"inputStage" : {
							"stage" : "SHARDING_FILTER",
							"nReturned" : 10,
							"executionTimeMillisEstimate" : 10,
							"works" : 21266,
							"advanced" : 10,
							"needTime" : 21255,
							"needYield" : 0,
							"saveState" : 166,
							"restoreState" : 166,
							"isEOF" : 1,
							"invalidates" : 0,
							"chunkSkips" : 0,
							"inputStage" : {
								"stage" : "IXSCAN",
								"filter" : {
									"_id" : {
										"$in" : [
											/hoge/
										]
									}
								},
								"nReturned" : 10,
								"executionTimeMillisEstimate" : 10,
								"works" : 21266,
								"advanced" : 10,
								"needTime" : 21255,
								"needYield" : 0,
								"saveState" : 166,
								"restoreState" : 166,
								"isEOF" : 1,
								"invalidates" : 0,
								"keyPattern" : {
									"_id" : 1
								},
								"indexName" : "_id_",
								"isMultiKey" : false,
								"isUnique" : true,
								"isSparse" : false,
								"isPartial" : false,
								"indexVersion" : 1,
								"direction" : "forward",
								"indexBounds" : {
									"_id" : [
										"[\"\", {})",
										"[/hoge/, /hoge/]"
									]
								},
								"keysExamined" : 21265,
								"dupsTested" : 0,
								"dupsDropped" : 0,
								"seenInvalidated" : 0
							}
						}
					}
				},
				{
					"shardName" : "production_5",
					"executionSuccess" : true,
					"executionStages" : {
						"stage" : "FETCH",
						"nReturned" : 7,
						"executionTimeMillisEstimate" : 30,
						"works" : 21248,
						"advanced" : 7,
						"needTime" : 21240,
						"needYield" : 0,
						"saveState" : 166,
						"restoreState" : 166,
						"isEOF" : 1,
						"invalidates" : 0,
						"docsExamined" : 7,
						"alreadyHasObj" : 0,
						"inputStage" : {
							"stage" : "SHARDING_FILTER",
							"nReturned" : 7,
							"executionTimeMillisEstimate" : 30,
							"works" : 21248,
							"advanced" : 7,
							"needTime" : 21240,
							"needYield" : 0,
							"saveState" : 166,
							"restoreState" : 166,
							"isEOF" : 1,
							"invalidates" : 0,
							"chunkSkips" : 0,
							"inputStage" : {
								"stage" : "IXSCAN",
								"filter" : {
									"_id" : {
										"$in" : [
											/hoge/
										]
									}
								},
								"nReturned" : 7,
								"executionTimeMillisEstimate" : 30,
								"works" : 21248,
								"advanced" : 7,
								"needTime" : 21240,
								"needYield" : 0,
								"saveState" : 166,
								"restoreState" : 166,
								"isEOF" : 1,
								"invalidates" : 0,
								"keyPattern" : {
									"_id" : 1
								},
								"indexName" : "_id_",
								"isMultiKey" : false,
								"isUnique" : true,
								"isSparse" : false,
								"isPartial" : false,
								"indexVersion" : 1,
								"direction" : "forward",
								"indexBounds" : {
									"_id" : [
										"[\"\", {})",
										"[/hoge/, /hoge/]"
									]
								},
								"keysExamined" : 21247,
								"dupsTested" : 0,
								"dupsDropped" : 0,
								"seenInvalidated" : 0
							}
						}
					}
				}
			]
		},
		"allPlansExecution" : [
			{
				"shardName" : "production_0",
				"allPlans" : [ ]
			},
			{
				"shardName" : "production_1",
				"allPlans" : [ ]
			},
			{
				"shardName" : "production_2",
				"allPlans" : [ ]
			},
			{
				"shardName" : "production_3",
				"allPlans" : [ ]
			},
			{
				"shardName" : "production_4",
				"allPlans" : [ ]
			},
			{
				"shardName" : "production_5",
				"allPlans" : [ ]
			}
		]
	},
	"ok" : 1
}

Comment by Suguru Namura [ 07/Jun/18 ]

Nick Brrewer

The result of explain is below.
DBName and Regexp match value are changed from the actual ones.

mongos> db.programs.find({_id: /hoge/}).explain(true)
{
	"queryPlanner" : {
		"mongosPlannerVersion" : 1,
		"winningPlan" : {
			"stage" : "SHARD_MERGE",
			"shards" : [
				{
					"shardName" : "production_0",
					"connectionString" : "production_0/prd-mongod-01-a.c.formidable-byte-89507.internal:27000,prd-mongod-01-b.c.formidable-byte-89507.internal:27000,prd-mongod-01-c.c.formidable-byte-89507.internal:27000,prd-mongod-04-a.c.formidable-byte-89507.internal:27000,prd-mongod-05-b.c.formidable-byte-89507.internal:27000,prd-mongod-06-c.c.formidable-byte-89507.internal:27000,prd-mongod-15-b.c.formidable-byte-89507.internal:27000,prd-mongod-15-c.c.formidable-byte-89507.internal:27000",
					"serverInfo" : {
						"host" : "prd-mongod-01-a",
						"port" : 27000,
						"version" : "3.2.16",
						"gitVersion" : "056bf45128114e44c5358c7a8776fb582363e094"
					},
					"plannerVersion" : 1,
					"namespace" : "dbname.programs",
					"indexFilterSet" : false,
					"parsedQuery" : {
						"_id" : /hoge/
					},
					"winningPlan" : {
						"stage" : "FETCH",
						"inputStage" : {
							"stage" : "SHARDING_FILTER",
							"inputStage" : {
								"stage" : "IXSCAN",
								"filter" : {
									"_id" : /hoge/
								},
								"keyPattern" : {
									"_id" : 1
								},
								"indexName" : "_id_",
								"isMultiKey" : false,
								"isUnique" : true,
								"isSparse" : false,
								"isPartial" : false,
								"indexVersion" : 1,
								"direction" : "forward",
								"indexBounds" : {
									"_id" : [
										"[\"\", {})",
										"[/hoge/, /hoge/]"
									]
								}
							}
						}
					},
					"rejectedPlans" : [ ]
				},
				{
					"shardName" : "production_1",
					"connectionString" : "production_1/prd-mongod-02-a.c.formidable-byte-89507.internal:27000,prd-mongod-02-b.c.formidable-byte-89507.internal:27000,prd-mongod-02-c.c.formidable-byte-89507.internal:27000,prd-mongod-04-b.c.formidable-byte-89507.internal:27000,prd-mongod-05-c.c.formidable-byte-89507.internal:27000,prd-mongod-06-a.c.formidable-byte-89507.internal:27000,prd-mongod-13-a.c.formidable-byte-89507.internal:27000,prd-mongod-13-b.c.formidable-byte-89507.internal:27000,prd-mongod-13-c.c.formidable-byte-89507.internal:27000,prd-mongod-14-a.c.formidable-byte-89507.internal:27000,prd-mongod-14-b.c.formidable-byte-89507.internal:27000,prd-mongod-14-c.c.formidable-byte-89507.internal:27000,prd-mongod-17-a.c.formidable-byte-89507.internal:27000,prd-mongod-17-b.c.formidable-byte-89507.internal:27000,prd-mongod-17-c.c.formidable-byte-89507.internal:27000",
					"serverInfo" : {
						"host" : "prd-mongod-02-a",
						"port" : 27000,
						"version" : "3.2.16",
						"gitVersion" : "056bf45128114e44c5358c7a8776fb582363e094"
					},
					"plannerVersion" : 1,
					"namespace" : "dbname.programs",
					"indexFilterSet" : false,
					"parsedQuery" : {
						"_id" : /hoge/
					},
					"winningPlan" : {
						"stage" : "FETCH",
						"inputStage" : {
							"stage" : "SHARDING_FILTER",
							"inputStage" : {
								"stage" : "IXSCAN",
								"filter" : {
									"_id" : /hoge/
								},
								"keyPattern" : {
									"_id" : 1
								},
								"indexName" : "_id_",
								"isMultiKey" : false,
								"isUnique" : true,
								"isSparse" : false,
								"isPartial" : false,
								"indexVersion" : 1,
								"direction" : "forward",
								"indexBounds" : {
									"_id" : [
										"[\"\", {})",
										"[/hoge/, /hoge/]"
									]
								}
							}
						}
					},
					"rejectedPlans" : [ ]
				},
				{
					"shardName" : "production_2",
					"connectionString" : "production_2/prd-mongod-03-a.c.formidable-byte-89507.internal:27000,prd-mongod-03-b.c.formidable-byte-89507.internal:27000,prd-mongod-03-c.c.formidable-byte-89507.internal:27000,prd-mongod-04-c.c.formidable-byte-89507.internal:27000,prd-mongod-05-a.c.formidable-byte-89507.internal:27000,prd-mongod-06-b.c.formidable-byte-89507.internal:27000,prd-mongod-18-b.c.formidable-byte-89507.internal:27000,prd-mongod-18-c.c.formidable-byte-89507.internal:27000,prd-mongod-19-a.c.formidable-byte-89507.internal:27000",
					"serverInfo" : {
						"host" : "prd-mongod-03-b",
						"port" : 27000,
						"version" : "3.2.16",
						"gitVersion" : "056bf45128114e44c5358c7a8776fb582363e094"
					},
					"plannerVersion" : 1,
					"namespace" : "dbname.programs",
					"indexFilterSet" : false,
					"parsedQuery" : {
						"_id" : /hoge/
					},
					"winningPlan" : {
						"stage" : "FETCH",
						"inputStage" : {
							"stage" : "SHARDING_FILTER",
							"inputStage" : {
								"stage" : "IXSCAN",
								"filter" : {
									"_id" : /hoge/
								},
								"keyPattern" : {
									"_id" : 1
								},
								"indexName" : "_id_",
								"isMultiKey" : false,
								"isUnique" : true,
								"isSparse" : false,
								"isPartial" : false,
								"indexVersion" : 1,
								"direction" : "forward",
								"indexBounds" : {
									"_id" : [
										"[\"\", {})",
										"[/hoge/, /hoge/]"
									]
								}
							}
						}
					},
					"rejectedPlans" : [ ]
				},
				{
					"shardName" : "production_3",
					"connectionString" : "production_3/prd-mongod-07-a.c.formidable-byte-89507.internal:27000,prd-mongod-07-b.c.formidable-byte-89507.internal:27000,prd-mongod-07-c.c.formidable-byte-89507.internal:27000,prd-mongod-10-a.c.formidable-byte-89507.internal:27000,prd-mongod-11-b.c.formidable-byte-89507.internal:27000,prd-mongod-12-c.c.formidable-byte-89507.internal:27000,prd-mongod-20-a.c.formidable-byte-89507.internal:27000,prd-mongod-20-b.c.formidable-byte-89507.internal:27000,prd-mongod-20-c.c.formidable-byte-89507.internal:27000",
					"serverInfo" : {
						"host" : "prd-mongod-07-b",
						"port" : 27000,
						"version" : "3.2.16",
						"gitVersion" : "056bf45128114e44c5358c7a8776fb582363e094"
					},
					"plannerVersion" : 1,
					"namespace" : "dbname.programs",
					"indexFilterSet" : false,
					"parsedQuery" : {
						"_id" : /hoge/
					},
					"winningPlan" : {
						"stage" : "FETCH",
						"inputStage" : {
							"stage" : "SHARDING_FILTER",
							"inputStage" : {
								"stage" : "IXSCAN",
								"filter" : {
									"_id" : /hoge/
								},
								"keyPattern" : {
									"_id" : 1
								},
								"indexName" : "_id_",
								"isMultiKey" : false,
								"isUnique" : true,
								"isSparse" : false,
								"isPartial" : false,
								"indexVersion" : 1,
								"direction" : "forward",
								"indexBounds" : {
									"_id" : [
										"[\"\", {})",
										"[/hoge/, /hoge/]"
									]
								}
							}
						}
					},
					"rejectedPlans" : [ ]
				},
				{
					"shardName" : "production_4",
					"connectionString" : "production_4/prd-mongod-08-a.c.formidable-byte-89507.internal:27000,prd-mongod-08-b.c.formidable-byte-89507.internal:27000,prd-mongod-08-c.c.formidable-byte-89507.internal:27000,prd-mongod-10-b.c.formidable-byte-89507.internal:27000,prd-mongod-11-c.c.formidable-byte-89507.internal:27000,prd-mongod-12-a.c.formidable-byte-89507.internal:27000,prd-mongod-22-a.c.formidable-byte-89507.internal:27000,prd-mongod-22-b.c.formidable-byte-89507.internal:27000,prd-mongod-22-c.c.formidable-byte-89507.internal:27000",
					"serverInfo" : {
						"host" : "prd-mongod-11-c",
						"port" : 27000,
						"version" : "3.2.16",
						"gitVersion" : "056bf45128114e44c5358c7a8776fb582363e094"
					},
					"plannerVersion" : 1,
					"namespace" : "dbname.programs",
					"indexFilterSet" : false,
					"parsedQuery" : {
						"_id" : /hoge/
					},
					"winningPlan" : {
						"stage" : "FETCH",
						"inputStage" : {
							"stage" : "SHARDING_FILTER",
							"inputStage" : {
								"stage" : "IXSCAN",
								"filter" : {
									"_id" : /hoge/
								},
								"keyPattern" : {
									"_id" : 1
								},
								"indexName" : "_id_",
								"isMultiKey" : false,
								"isUnique" : true,
								"isSparse" : false,
								"isPartial" : false,
								"indexVersion" : 1,
								"direction" : "forward",
								"indexBounds" : {
									"_id" : [
										"[\"\", {})",
										"[/hoge/, /hoge/]"
									]
								}
							}
						}
					},
					"rejectedPlans" : [ ]
				},
				{
					"shardName" : "production_5",
					"connectionString" : "production_5/prd-mongod-09-a.c.formidable-byte-89507.internal:27000,prd-mongod-09-b.c.formidable-byte-89507.internal:27000,prd-mongod-09-c.c.formidable-byte-89507.internal:27000,prd-mongod-10-c.c.formidable-byte-89507.internal:27000,prd-mongod-11-a.c.formidable-byte-89507.internal:27000,prd-mongod-12-b.c.formidable-byte-89507.internal:27000,prd-mongod-23-c.c.formidable-byte-89507.internal:27000,prd-mongod-24-a.c.formidable-byte-89507.internal:27000",
					"serverInfo" : {
						"host" : "prd-mongod-11-a",
						"port" : 27000,
						"version" : "3.2.16",
						"gitVersion" : "056bf45128114e44c5358c7a8776fb582363e094"
					},
					"plannerVersion" : 1,
					"namespace" : "dbname.programs",
					"indexFilterSet" : false,
					"parsedQuery" : {
						"_id" : /hoge/
					},
					"winningPlan" : {
						"stage" : "FETCH",
						"inputStage" : {
							"stage" : "SHARDING_FILTER",
							"inputStage" : {
								"stage" : "IXSCAN",
								"filter" : {
									"_id" : /hoge/
								},
								"keyPattern" : {
									"_id" : 1
								},
								"indexName" : "_id_",
								"isMultiKey" : false,
								"isUnique" : true,
								"isSparse" : false,
								"isPartial" : false,
								"indexVersion" : 1,
								"direction" : "forward",
								"indexBounds" : {
									"_id" : [
										"[\"\", {})",
										"[/hoge/, /hoge/]"
									]
								}
							}
						}
					},
					"rejectedPlans" : [ ]
				}
			]
		}
	},
	"executionStats" : {
		"nReturned" : 51,
		"executionTimeMillis" : 52,
		"totalKeysExamined" : 122568,
		"totalDocsExamined" : 51,
		"executionStages" : {
			"stage" : "SHARD_MERGE",
			"nReturned" : 51,
			"executionTimeMillis" : 52,
			"totalKeysExamined" : 122568,
			"totalDocsExamined" : 51,
			"totalChildMillis" : NumberLong(205),
			"shards" : [
				{
					"shardName" : "production_0",
					"executionSuccess" : true,
					"executionStages" : {
						"stage" : "FETCH",
						"nReturned" : 8,
						"executionTimeMillisEstimate" : 20,
						"works" : 22226,
						"advanced" : 8,
						"needTime" : 22217,
						"needYield" : 0,
						"saveState" : 173,
						"restoreState" : 173,
						"isEOF" : 1,
						"invalidates" : 0,
						"docsExamined" : 8,
						"alreadyHasObj" : 0,
						"inputStage" : {
							"stage" : "SHARDING_FILTER",
							"nReturned" : 8,
							"executionTimeMillisEstimate" : 20,
							"works" : 22226,
							"advanced" : 8,
							"needTime" : 22217,
							"needYield" : 0,
							"saveState" : 173,
							"restoreState" : 173,
							"isEOF" : 1,
							"invalidates" : 0,
							"chunkSkips" : 0,
							"inputStage" : {
								"stage" : "IXSCAN",
								"filter" : {
									"_id" : /hoge/
								},
								"nReturned" : 8,
								"executionTimeMillisEstimate" : 20,
								"works" : 22226,
								"advanced" : 8,
								"needTime" : 22217,
								"needYield" : 0,
								"saveState" : 173,
								"restoreState" : 173,
								"isEOF" : 1,
								"invalidates" : 0,
								"keyPattern" : {
									"_id" : 1
								},
								"indexName" : "_id_",
								"isMultiKey" : false,
								"isUnique" : true,
								"isSparse" : false,
								"isPartial" : false,
								"indexVersion" : 1,
								"direction" : "forward",
								"indexBounds" : {
									"_id" : [
										"[\"\", {})",
										"[/hoge/, /hoge/]"
									]
								},
								"keysExamined" : 22225,
								"dupsTested" : 0,
								"dupsDropped" : 0,
								"seenInvalidated" : 0
							}
						}
					}
				},
				{
					"shardName" : "production_1",
					"executionSuccess" : true,
					"executionStages" : {
						"stage" : "FETCH",
						"nReturned" : 6,
						"executionTimeMillisEstimate" : 30,
						"works" : 19419,
						"advanced" : 6,
						"needTime" : 19412,
						"needYield" : 0,
						"saveState" : 151,
						"restoreState" : 151,
						"isEOF" : 1,
						"invalidates" : 0,
						"docsExamined" : 6,
						"alreadyHasObj" : 0,
						"inputStage" : {
							"stage" : "SHARDING_FILTER",
							"nReturned" : 6,
							"executionTimeMillisEstimate" : 30,
							"works" : 19419,
							"advanced" : 6,
							"needTime" : 19412,
							"needYield" : 0,
							"saveState" : 151,
							"restoreState" : 151,
							"isEOF" : 1,
							"invalidates" : 0,
							"chunkSkips" : 0,
							"inputStage" : {
								"stage" : "IXSCAN",
								"filter" : {
									"_id" : /hoge/
								},
								"nReturned" : 6,
								"executionTimeMillisEstimate" : 30,
								"works" : 19419,
								"advanced" : 6,
								"needTime" : 19412,
								"needYield" : 0,
								"saveState" : 151,
								"restoreState" : 151,
								"isEOF" : 1,
								"invalidates" : 0,
								"keyPattern" : {
									"_id" : 1
								},
								"indexName" : "_id_",
								"isMultiKey" : false,
								"isUnique" : true,
								"isSparse" : false,
								"isPartial" : false,
								"indexVersion" : 1,
								"direction" : "forward",
								"indexBounds" : {
									"_id" : [
										"[\"\", {})",
										"[/hoge/, /hoge/]"
									]
								},
								"keysExamined" : 19418,
								"dupsTested" : 0,
								"dupsDropped" : 0,
								"seenInvalidated" : 0
							}
						}
					}
				},
				{
					"shardName" : "production_2",
					"executionSuccess" : true,
					"executionStages" : {
						"stage" : "FETCH",
						"nReturned" : 7,
						"executionTimeMillisEstimate" : 50,
						"works" : 19113,
						"advanced" : 7,
						"needTime" : 19105,
						"needYield" : 0,
						"saveState" : 149,
						"restoreState" : 149,
						"isEOF" : 1,
						"invalidates" : 0,
						"docsExamined" : 7,
						"alreadyHasObj" : 0,
						"inputStage" : {
							"stage" : "SHARDING_FILTER",
							"nReturned" : 7,
							"executionTimeMillisEstimate" : 50,
							"works" : 19113,
							"advanced" : 7,
							"needTime" : 19105,
							"needYield" : 0,
							"saveState" : 149,
							"restoreState" : 149,
							"isEOF" : 1,
							"invalidates" : 0,
							"chunkSkips" : 0,
							"inputStage" : {
								"stage" : "IXSCAN",
								"filter" : {
									"_id" : /hoge/
								},
								"nReturned" : 7,
								"executionTimeMillisEstimate" : 50,
								"works" : 19113,
								"advanced" : 7,
								"needTime" : 19105,
								"needYield" : 0,
								"saveState" : 149,
								"restoreState" : 149,
								"isEOF" : 1,
								"invalidates" : 0,
								"keyPattern" : {
									"_id" : 1
								},
								"indexName" : "_id_",
								"isMultiKey" : false,
								"isUnique" : true,
								"isSparse" : false,
								"isPartial" : false,
								"indexVersion" : 1,
								"direction" : "forward",
								"indexBounds" : {
									"_id" : [
										"[\"\", {})",
										"[/hoge/, /hoge/]"
									]
								},
								"keysExamined" : 19112,
								"dupsTested" : 0,
								"dupsDropped" : 0,
								"seenInvalidated" : 0
							}
						}
					}
				},
				{
					"shardName" : "production_3",
					"executionSuccess" : true,
					"executionStages" : {
						"stage" : "FETCH",
						"nReturned" : 13,
						"executionTimeMillisEstimate" : 40,
						"works" : 19302,
						"advanced" : 13,
						"needTime" : 19288,
						"needYield" : 0,
						"saveState" : 150,
						"restoreState" : 150,
						"isEOF" : 1,
						"invalidates" : 0,
						"docsExamined" : 13,
						"alreadyHasObj" : 0,
						"inputStage" : {
							"stage" : "SHARDING_FILTER",
							"nReturned" : 13,
							"executionTimeMillisEstimate" : 40,
							"works" : 19302,
							"advanced" : 13,
							"needTime" : 19288,
							"needYield" : 0,
							"saveState" : 150,
							"restoreState" : 150,
							"isEOF" : 1,
							"invalidates" : 0,
							"chunkSkips" : 0,
							"inputStage" : {
								"stage" : "IXSCAN",
								"filter" : {
									"_id" : /hoge/
								},
								"nReturned" : 13,
								"executionTimeMillisEstimate" : 40,
								"works" : 19302,
								"advanced" : 13,
								"needTime" : 19288,
								"needYield" : 0,
								"saveState" : 150,
								"restoreState" : 150,
								"isEOF" : 1,
								"invalidates" : 0,
								"keyPattern" : {
									"_id" : 1
								},
								"indexName" : "_id_",
								"isMultiKey" : false,
								"isUnique" : true,
								"isSparse" : false,
								"isPartial" : false,
								"indexVersion" : 1,
								"direction" : "forward",
								"indexBounds" : {
									"_id" : [
										"[\"\", {})",
										"[/hoge/, /hoge/]"
									]
								},
								"keysExamined" : 19301,
								"dupsTested" : 0,
								"dupsDropped" : 0,
								"seenInvalidated" : 0
							}
						}
					}
				},
				{
					"shardName" : "production_4",
					"executionSuccess" : true,
					"executionStages" : {
						"stage" : "FETCH",
						"nReturned" : 10,
						"executionTimeMillisEstimate" : 30,
						"works" : 21266,
						"advanced" : 10,
						"needTime" : 21255,
						"needYield" : 0,
						"saveState" : 166,
						"restoreState" : 166,
						"isEOF" : 1,
						"invalidates" : 0,
						"docsExamined" : 10,
						"alreadyHasObj" : 0,
						"inputStage" : {
							"stage" : "SHARDING_FILTER",
							"nReturned" : 10,
							"executionTimeMillisEstimate" : 30,
							"works" : 21266,
							"advanced" : 10,
							"needTime" : 21255,
							"needYield" : 0,
							"saveState" : 166,
							"restoreState" : 166,
							"isEOF" : 1,
							"invalidates" : 0,
							"chunkSkips" : 0,
							"inputStage" : {
								"stage" : "IXSCAN",
								"filter" : {
									"_id" : /hoge/
								},
								"nReturned" : 10,
								"executionTimeMillisEstimate" : 30,
								"works" : 21266,
								"advanced" : 10,
								"needTime" : 21255,
								"needYield" : 0,
								"saveState" : 166,
								"restoreState" : 166,
								"isEOF" : 1,
								"invalidates" : 0,
								"keyPattern" : {
									"_id" : 1
								},
								"indexName" : "_id_",
								"isMultiKey" : false,
								"isUnique" : true,
								"isSparse" : false,
								"isPartial" : false,
								"indexVersion" : 1,
								"direction" : "forward",
								"indexBounds" : {
									"_id" : [
										"[\"\", {})",
										"[/hoge/, /hoge/]"
									]
								},
								"keysExamined" : 21265,
								"dupsTested" : 0,
								"dupsDropped" : 0,
								"seenInvalidated" : 0
							}
						}
					}
				},
				{
					"shardName" : "production_5",
					"executionSuccess" : true,
					"executionStages" : {
						"stage" : "FETCH",
						"nReturned" : 7,
						"executionTimeMillisEstimate" : 30,
						"works" : 21248,
						"advanced" : 7,
						"needTime" : 21240,
						"needYield" : 0,
						"saveState" : 166,
						"restoreState" : 166,
						"isEOF" : 1,
						"invalidates" : 0,
						"docsExamined" : 7,
						"alreadyHasObj" : 0,
						"inputStage" : {
							"stage" : "SHARDING_FILTER",
							"nReturned" : 7,
							"executionTimeMillisEstimate" : 30,
							"works" : 21248,
							"advanced" : 7,
							"needTime" : 21240,
							"needYield" : 0,
							"saveState" : 166,
							"restoreState" : 166,
							"isEOF" : 1,
							"invalidates" : 0,
							"chunkSkips" : 0,
							"inputStage" : {
								"stage" : "IXSCAN",
								"filter" : {
									"_id" : /hoge/
								},
								"nReturned" : 7,
								"executionTimeMillisEstimate" : 30,
								"works" : 21248,
								"advanced" : 7,
								"needTime" : 21240,
								"needYield" : 0,
								"saveState" : 166,
								"restoreState" : 166,
								"isEOF" : 1,
								"invalidates" : 0,
								"keyPattern" : {
									"_id" : 1
								},
								"indexName" : "_id_",
								"isMultiKey" : false,
								"isUnique" : true,
								"isSparse" : false,
								"isPartial" : false,
								"indexVersion" : 1,
								"direction" : "forward",
								"indexBounds" : {
									"_id" : [
										"[\"\", {})",
										"[/hoge/, /hoge/]"
									]
								},
								"keysExamined" : 21247,
								"dupsTested" : 0,
								"dupsDropped" : 0,
								"seenInvalidated" : 0
							}
						}
					}
				}
			]
		},
		"allPlansExecution" : [
			{
				"shardName" : "production_0",
				"allPlans" : [ ]
			},
			{
				"shardName" : "production_1",
				"allPlans" : [ ]
			},
			{
				"shardName" : "production_2",
				"allPlans" : [ ]
			},
			{
				"shardName" : "production_3",
				"allPlans" : [ ]
			},
			{
				"shardName" : "production_4",
				"allPlans" : [ ]
			},
			{
				"shardName" : "production_5",
				"allPlans" : [ ]
			}
		]
	},
	"ok" : 1
}

Comment by Nick Brewer [ 06/Jun/18 ]

 service@abema.tv I'd like to see the full explain output for both queries:

db.programs.find({ _id: /hoge/ }).explain(true)

db.programs.find({_id: {$in: [/hoge/] }}).explain(true)

Regards,

Nick

Comment by Suguru Namura [ 06/Jun/18 ]

sorry, sample query result was opposite.
It is correct below.

mongos> db.programs.find({ _id: /hoge/ }).count()
51

mongos> db.programs.find({_id: {$in: [/hoge/] }}).count()
0

Generated at Thu Feb 08 04:39:52 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.