[SERVER-30205] Report warning if requested key(s) is not found when creating index Created: 18/Jul/17  Updated: 29/Jan/24

Status: Backlog
Project: Core Server
Component/s: Index Maintenance
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Chris Harris Assignee: Backlog - Storage Execution Team
Resolution: Unresolved Votes: 2
Labels: execution-product-sync, neweng, oldstorexemea, pmr, storex-ranked
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Storage Execution
Participants:
Case:

 Description   

We should consider reporting a warning if an index build on a non-empty collection does not encounter any documents containing the key(s) specified. This can happen, for example, if there is a typo in the command. Such a warning could help mitigate performance issues and reduce the time and resources required to investigate and correct.

> db.bar.findOne()
{
	"_id" : ObjectId("596e1e46970f5ca6dfaaf7d7"),
	"address" : "123 Main Street"
}
>
>//It would be nice if the output of the following command indicated that the misspelled "adress" field was not found while building the index
>
> db.bar.createIndex({adress:1})
{
	"createdCollectionAutomatically" : false,
	"numIndexesBefore" : 1,
	"numIndexesAfter" : 2,
	"ok" : 1
}
> 
> db.bar.find({"address" : "123 Main Street"}).explain()
{
	"queryPlanner" : {
		"plannerVersion" : 1,
		"namespace" : "foo.bar",
		"indexFilterSet" : false,
		"parsedQuery" : {
			"address" : {
				"$eq" : "123 Main Street"
			}
		},
		"winningPlan" : {
			"stage" : "COLLSCAN",
			"filter" : {
				"address" : {
					"$eq" : "123 Main Street"
				}
			},
			"direction" : "forward"
		},
		"rejectedPlans" : [ ]
	},
}



 Comments   
Comment by Dianna Hohensee (Inactive) [ 07/Feb/23 ]

Triage conversation: can we leave a note in the command response when this happens? If every single field value is null for an index, surface this.

Comment by Ana Meza [ 25/Oct/22 ]

james.wahlin@mongodb.com I am assigning this to you as discussed during QO Triage meeting

Comment by Asya Kamsky [ 07/Apr/22 ]

Why not make it a more general info message:

 

”Found X distinct values when building this index” ?  

Comment by Chris Harris [ 27/Sep/17 ]

Regarding preemptively creating an index (for an incoming field), that's absolutely a possibility. Users issuing the command in that situation are probably already aware and expecting that the field will not be found. But the intention is that the warning would be worded in such a way to note this possibility (and that it is not a problem).

Since the mongo shell session creating the index [in the background] will block until the index build is complete, this warning could be applied in either situation.

Comment by Kyle Suarez [ 18/Jul/17 ]

What if I want to preemptively create an index for some new field that will be inserted for future documents? I suppose a warning wouldn't really hurt, but it sounds like a product like Compass would make the most use of this feature, as it has a sample of the documents in the collection.

In any case. it sounds like this would only be possible for foreground index builds.

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