[SERVER-5759] indexOnly in explain() is not reported correctly Created: 03/May/12  Updated: 03/Mar/15  Resolved: 11/Feb/15

Status: Closed
Project: Core Server
Component/s: Diagnostics, Index Maintenance, Querying
Affects Version/s: None
Fix Version/s: 2.8.0-rc0

Type: Bug Priority: Minor - P4
Reporter: siddharth.singh@10gen.com Assignee: Unassigned
Resolution: Done Votes: 2
Labels: coveredIndex, query_triage
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by SERVER-8549 Not in covered index query does not h... Closed
is duplicated by SERVER-8551 Exists query with a sparse index shou... Closed
is duplicated by SERVER-8562 indexOnly should be false when sortin... Closed
is duplicated by SERVER-10959 indexOnly is wrong sometimes Closed
Related
related to DOCS-198 indexOnly on explain page needs corre... Closed
related to SERVER-5019 covered indexes are not implemented f... Closed
related to SERVER-10448 Revamp explain() formatting Closed
is related to SERVER-4161 nscannedObjects is not calculated pro... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Participants:

 Description   

Expected indexOnly:false but it is reported as true.

 
skipjack:test> db.foo.find()
{ "_id" : ObjectId("4fa2ad3315f3f440e6aee399"), "a" : 1, "b" : 2 }
{ "_id" : ObjectId("4fa2ad3715f3f440e6aee39a"), "a" : 2, "b" : 2, "c" : 2 }
 
skipjack:test> db.foo.find({a: 1, b:2, c: {$exists: false}}, {_id: 0, a:1}).explain().indexOnly
true
 
skipjack:test> db.foo.find({a: 1, b:2, c: {$exists: false}}, {_id: 0, a:1, c:1}).explain().indexOnly
false
 
skipjack:test> db.foo.getIndexKeys()
[ { "_id" : 1 }, { "a" : 1, "b" : 1 } ]
 



 Comments   
Comment by Asya Kamsky [ 11/Feb/15 ]

Resolved via explain plan changes for 3.0.0

Comment by A. Jesse Jiryu Davis [ 09/Jul/13 ]

For example:

> db.test.getIndexes()
[
	{
		"v" : 1,
		"key" : {
			"_id" : 1
		},
		"ns" : "test.test",
		"name" : "_id_"
	},
	{
		"v" : 1,
		"key" : {
			"a" : 1
		},
		"ns" : "test.test",
		"name" : "a_1"
	}
]
> db.test.find({a:{$gt:1}})._addSpecial("$returnKey", true )
{ "a" : 2 }
{ "a" : 4 }
{ "a" : 4 }
> db.test.find({a:{$gt:1}})._addSpecial("$returnKey", true ).explain().cursor
BtreeCursor a_1
> db.test.find({a:{$gt:1}})._addSpecial("$returnKey", true ).explain().indexOnly
false

Comment by auto [ 14/Feb/13 ]

Author:

{u'date': u'2013-02-15T06:26:56Z', u'name': u'aaron', u'email': u'aaron@10gen.com'}

Message: SERVER-8575 SERVER-4161 SERVER-5759 Disable descriptive testing of erroneous indexOnly reporting when the behavior is inconsistent in a sharded environment. Fixes sharding_passthrough/covered_index_negative1 test.
Branch: master
https://github.com/mongodb/mongo/commit/2d71e6ab2d42c3c1cc31d42e579dec8041f6cca4

Comment by Aaron Staple [ 12/Sep/12 ]

List (partial) of criteria that go into determining whether a query is index only (these should be used for reporting):

  • Projection::KeyOnly in use
  • $returnKey specified
  • scan and order sort applied
  • matcher loads doc
  • doc loaded for $or clause deduplication

Currently the reported indexOnly field is just based on Projection::KeyOnly.

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