[SERVER-8776] Querying on $keyname is possible and leads to collection scans Created: 28/Feb/13  Updated: 18/Aug/14  Resolved: 18/Aug/14

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

Type: Improvement Priority: Major - P3
Reporter: Andre de Frere Assignee: Unassigned
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
Participants:

 Description   

A query can be created to scan for a non existent key that starts with a $.

These fields are not permitted to be inserted, but can still be queried on. This leads to a collection scan, which can have many performance impacts.

If the $ character denotes an operator (like $inc, $date etc) then when some unknown operator is found, it should be rejected by the query rather than cause a collection scan. In this way queries like

db.test.find({$keyname:1})

would fail.



 Comments   
Comment by Thomas Rueckstiess [ 18/Aug/14 ]

This is fixed in 2.6:

> db.test.find({$keyname:1})
error: {
	"$err" : "Can't canonicalize query: BadValue unknown top level operator: $keyname",
	"code" : 17287
}

Generated at Thu Feb 08 03:18:25 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.