[DOCS-7337] count will now respect a hint with no query predicate Created: 03/Mar/16  Updated: 30/Oct/23  Resolved: 01/Nov/22

Status: Closed
Project: Documentation
Component/s: manual, Server
Affects Version/s: None
Fix Version/s: Server_Docs_20231030

Type: Task Priority: Major - P3
Reporter: Charlie Swanson Assignee: Unassigned
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:
Days since reply: 1 year, 14 weeks, 1 day ago
Epic Link: DOCSP-1769

 Description   

We fixed SERVER-22041, which is a backwards breaking change. This should make it into the compatibility notes.

Previous behavior:

> db.foo.drop()
true
> db.foo.ensureIndex({a: 1}, {sparse: true})
{
	"createdCollectionAutomatically" : true,
	"numIndexesBefore" : 1,
	"numIndexesAfter" : 2,
	"ok" : 1
}
> db.foo.insert({})
WriteResult({ "nInserted" : 1 })
> db.foo.find().hint({a: 1}).count()
1  // Unexpected: should return 0 instead.

New behavior:

> db.foo.drop()
true
> db.foo.ensureIndex({a: 1}, {sparse: true})
{
	"createdCollectionAutomatically" : true,
	"numIndexesBefore" : 1,
	"numIndexesAfter" : 2,
	"ok" : 1
}
> db.foo.insert({})
WriteResult({ "nInserted" : 1 })
> db.foo.find().hint({a: 1}).count()
0  // Weird, but this is consistent with how the find command respects hints.



 Comments   
Comment by Education Bot [ 01/Nov/22 ]

Hello! This ticket has been closed due to inactivity. If you believe this ticket is still important, please reopen it and leave a comment to explain why. Thank you!

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