[SERVER-22857] eliminate redundant conditions/clauses from query Created: 25/Feb/16  Updated: 19/Dec/23  Resolved: 19/Dec/23

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

Type: Improvement Priority: Major - P3
Reporter: Asya Kamsky Assignee: Backlog - Query Optimization
Resolution: Duplicate Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by SERVER-75079 Simplify boolean expressions before f... Closed
Related
related to SERVER-31360 MatchExpression::getOptimizer() for $... Closed
is related to SERVER-60373 Duplicate predicates in query plan fo... Closed
is related to SERVER-81788 Optimize $elemMatch in the Boolean ex... Backlog
is related to SERVER-75079 Simplify boolean expressions before f... Closed
Assigned Teams:
Query Optimization
Participants:

 Description   

When query format is something like

db.foo.find( {$and: [ { "a" : 1 }, { "a" : 1 } ] });
 
db.foo.find({ "a": {"id":1}, "a":{$elemMatch:{"id":1, "b":9} } });

In both cases one of the query parts is 100% redundant of the rest. This is to track optimizing it out of query consideration/evaluation.



 Comments   
Comment by Asya Kamsky [ 10/Jul/20 ]

A couple of examples that came up that should probably be handled under this work:

{a:{$ne:null, $exists:true}}
{a:{$gt:1, $exists:true}}

In fact, $exists clause is redundant alongside many/most other clauses on the same field, except null equality(there may be another one or two). Note that we don't have this problematic behavior if it is a type check along with value comparison that already requires that type, I believe we fixed that when implementing partial index filters.

Closely related ticket is SERVER-31360 (for $or clauses, this one is for $and clauses).

Comment by NOVALUE Mitar [ 06/Apr/16 ]

This is important also because redundant clauses can throw unnecessary errors because they look like query might be ambiguous, see SERVER-18500.

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