[SERVER-80324] Support lowering $_internalUnpackBucket with eventFilter having discarded fields Created: 23/Aug/23  Updated: 29/Oct/23  Resolved: 12/Oct/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 7.2.0-rc0

Type: Task Priority: Major - P3
Reporter: Yoon Soo Kim Assignee: Irina Yatsenko (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Query Integration
Backwards Compatibility: Fully Compatible
Sprint: QI 2023-10-16
Participants:

 Description   

Repro

> db.ts3.explain().aggregate([{$project: {y: 1}}, {$match: {x: {$lt: 0}}}]);
{
	"explainVersion" : "1",
	"stages" : [
		{
			"$cursor" : {
				"queryPlanner" : {
					"namespace" : "test.system.buckets.ts3",
					"indexFilterSet" : false,
					"parsedQuery" : {
 
					},
					"queryHash" : "FCBE9F38",
					"planCacheKey" : "FCBE9F38",
					"maxIndexedOrSolutionsReached" : false,
					"maxIndexedAndSolutionsReached" : false,
					"maxScansToExplodeReached" : false,
					"winningPlan" : {
						"stage" : "COLLSCAN",
						"direction" : "forward"
					},
					"rejectedPlans" : [ ]
				}
			}
		},
		{
			"$_internalUnpackBucket" : {
				"include" : [
					"_id",
					"y"
				],
				"timeField" : "time",
				"metaField" : "mm",
				"bucketMaxSpanSeconds" : 3600,
				"assumeNoMixedSchemaData" : true,
				"eventFilter" : {
					"x" : {
						"$lt" : 0
					}
				}
			}
		}
	],

The eventFilter has the discarded field x. If any top-level field of the 'eventFilter' is not in the bucketSpec's fieldSet, then it's a discarded field and we cannot push down the stage because the SBE filter generator cannot refer to slot(s) for the discarded field(s) which are not returned from 'block_to_row' stage. It would be better to optimize such event filter further so that it does not include any discarded field(s).



 Comments   
Comment by Githook User [ 12/Oct/23 ]

Author:

{'name': 'Irina Yatsenko', 'email': 'irina.yatsenko@mongodb.com', 'username': 'IrinaYatsenko'}

Message: SERVER-80324 Lower to SBE ts-queries with filter on a non-unpacked field
Branch: master
https://github.com/mongodb/mongo/commit/f53a71181386cd8c9a49fdc5ad1cc8980c114b6b

Generated at Thu Feb 08 06:43:15 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.