[SERVER-8561] Query with sort ($natural:1) is reported as indexOnly when it should not be Created: 13/Feb/13  Updated: 18/Feb/13  Resolved: 14/Feb/13

Status: Closed
Project: Core Server
Component/s: Index Maintenance
Affects Version/s: 2.4.0-rc0
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Sridhar Nanjundeswaran Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-8564 Clean up unneeded code for $natural h... Backlog
Operating System: ALL
Steps To Reproduce:

var coll = db.getCollection("covered_negative_1")
coll.drop()
for (i=0;i<100;i++) {
coll.insert(

{a:i, b:"strvar_"+(i%13), c:NumberInt(i%10), d: i*10, e: [i, i%10]}

)
}
coll.insert
coll.ensureIndex(

{a:1,b:-1,c:1}

)
coll.ensureIndex(

{e:1}

)
coll.ensureIndex(

{d:1}

)
// Test projection and $natural sort
var plan = coll.find({a:{$gt:70}},

{a:1, b:1, c:1, _id:0}

).sort({$natural:1}).hint(

{a:1, b:-1, c:1}

).explain()
assert.eq(false, plan.indexOnly, "negative.1.5 - indexOnly should be false on a non covered query")

Participants:

 Description   

Query with sort ($natural:1) should not be a covered query. The test below asserts with
[false] != [true] are not equal : negative.1.5 - indexOnly should be false on a non covered query



 Comments   
Comment by Aaron Staple [ 14/Feb/13 ]

Hi Sridhar - I think the root issue here is that $natural sort is being ignored when a hint that cannot provide natural ordering is specified. I filed SERVER-8564 to address this.

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