[SERVER-1364] don't require scan and order when sort spec can have only one value Created: 06/Jul/10  Updated: 01/Apr/15  Resolved: 01/Apr/15

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

Type: Bug Priority: Major - P3
Reporter: Aaron Staple Assignee: David Storch
Resolution: Incomplete Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Participants:

 Description   

> db.f.drop()
true
> db.f.ensureIndex( {a:1,b:1} );
> db.f.find( {a:[1,2],b:1} ).sort( {b:1} ).explain()
{
	"cursor" : "BtreeCursor a_1_b_1 multi",
	"nscanned" : 0,
	"nscannedObjects" : 0,
	"n" : 0,
	"scanAndOrder" : true,
	"millis" : 4,
	"indexBounds" : [
		[
			{
				"a" : 1,
				"b" : 1
			},
			{
				"a" : 1,
				"b" : 1
			}
		],
		[
			{
				"a" : [
					1,
					2
				],
				"b" : 1
			},
			{
				"a" : [
					1,
					2
				],
				"b" : 1
			}
		]
	]
}
> 



 Comments   
Comment by Aaron Staple [ 19/Jul/11 ]

I think because of what we did for SERVER-2884 this may be ok in the multikey case.

Comment by Aaron Staple [ 30/Mar/11 ]

We probably don't want to do this right now, because this optimization is only valid when the equality field is not multikey, and if the query yields the equality field could become multikey even if it was not before. And it wouldn't be possible to then switch on scan and order if the multikey status changes.

Generated at Thu Feb 08 02:56:49 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.