[SERVER-77499] [CQF] Add predicates to SargableNode about fields which are implied by existing predicates on dotted fields Created: 25/May/23  Updated: 12/Jun/23

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

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

Issue Links:
Related
related to SERVER-70780 [CQF] Simplify redundant PathObj / im... Backlog
Assigned Teams:
Query Optimization
Participants:

 Description   

Consider a non-multikey index on {a: 1} and the query {a: {b: 123{}}. We might end up with a SargableNode with requirements PathGet [a] PathGet [b] PathIdentity [] = 123. We will consider a plan which does an IXSCAN + SEEK, with no bounds onĀ 

{a: 1}

. However, because we know the predicate in the query implies that a is an object, we can actually produce tighter bounds on the IXSCAN [{}, []] over a. See BSON sort ordering.

The purpose of this ticket is to explore whether we can achieve these tighter index bounds. One solution could add a rewrite that adds (perfOnly?) partial schema requirements to SargableNodes on fields which are implied by existing requirements. Another options could be to modify the index bounds generation to take into account these types.

Another area to think about is if we can do a similar transformation for multikey indexes (PathGet[a] PathTraverse[1] PathGet[b] PathIdentity[])?



 Comments   
Comment by David Percy [ 12/Jun/23 ]

I think implementing this ticket would partially solve SERVER-70780. First we introduce explicit PathObj predicates. Then as a second step we could detect and eliminate things like (ComposeM PathObj PathArr).

Comment by David Percy [ 12/Jun/23 ]

This looks related to SERVER-70780, because both involve detecting whether a predicate is only true for objects.

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