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

Report warning if requested key(s) is not found when creating index

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Major - P3
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: Backlog
    • Component/s: Indexing
    • Labels:
      None
    • 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" : [ ]
      	},
      }
      

        Attachments

          Activity

            People

            Assignee:
            backlog-query-optimization Backlog - Query Optimization
            Reporter:
            christopher.harris Christopher Harris
            Participants:
            Votes:
            2 Vote for this issue
            Watchers:
            11 Start watching this issue

              Dates

              Created:
              Updated: