[SERVER-43770] Move fetch after random sort in $sample Created: 02/Oct/19  Updated: 21/Jan/23

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

Type: Improvement Priority: Major - P3
Reporter: Kevin Arhelger Assignee: Backlog - Query Optimization
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Text File explain.txt    
Issue Links:
Depends
Related
Assigned Teams:
Query Optimization
Participants:
Case:

 Description   

Consider the following aggregation on a uniform collection with a [0,999999] (with an index onĀ {a:1}

[
	{
		"$match" : {
			"$and" : [
				{
					"a" : {
						"$gte" : 500000
					}
				},
				{
					"a" : {
						"$lte" : 700000
					}
				}
			]
		}
	},
	{
		"$sample" : {
			"size" : 25
		}
	}
]

This will examine 200001 documents, but in this case, only the record locator needs to be random sorted and 25 documents fetched after record locators are chosen.



 Comments   
Comment by Carl Champain (Inactive) [ 03/Oct/19 ]

This ticket has been passed along to the Query team for further consideration.

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