[SERVER-71524] [CQF] Invalid index scan plan constructed for compound query Created: 21/Nov/22  Updated: 29/Oct/23  Resolved: 20/Dec/22

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

Type: Bug Priority: Major - P3
Reporter: Hana Pearlman Assignee: David Percy
Resolution: Fixed Votes: 0
Labels: auto-reverted
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Problem/Incident
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: QO 2022-12-12, QO 2022-12-26
Participants:
Linked BF Score: 162

 Description   

I have a set of documents that I insert into a collection, I create a compound index {a: 1, x: 1} and then I run a query:

{$match: {$and: [ { "a.b" : 1 }, { "a.x" : 1 } ]}} 

The optimizer constructs a plan which fails to match the following document:

{a: [{b: 1}, {x: 1}]}.  

The plan chosen by the optimizer is an index scan followed by two filters, one for the a.b predicate and one for the a.x predicate, and then the fetch comes later. The problem is that the two filter are applied to the index keys, so only a key that matches both predicates under the $and will pass the filters. But, if ‘a’ is an array, it may have multiple index keys, one which satisfies the first filter and one which satisfies the second. This would match in classic. 



 Comments   
Comment by Githook User [ 12/Dec/22 ]

Author:

{'name': 'David Percy', 'email': 'david.percy@mongodb.com', 'username': 'dpercy'}

Message: SERVER-71524 [CQF] Don't use one ixscan for two independent traverses
Branch: master
https://github.com/mongodb/mongo/commit/bb7a7e20dfb1a86bb9378ea4254275ef78592d72

Comment by xgen-buildbaron-user [ 08/Dec/22 ]

Ticket re-opened due to revert. run_unittests began a consistent failure of build/install/bin/optimizer_test

Comment by Githook User [ 08/Dec/22 ]

Author:

{'name': 'auto-revert-processor', 'email': 'dev-prod-dag@mongodb.com'}

Message: Revert "SERVER-71524 [CQF] Don't use one ixscan for two independent traverses"

This reverts commit afcba3c5c0d7214ea222dc7e56a897864023aabe.
Branch: master
https://github.com/mongodb/mongo/commit/6327fdb3b4deb599d694ee36350e9d0e0322817a

Comment by Githook User [ 07/Dec/22 ]

Author:

{'name': 'David Percy', 'email': 'david.percy@mongodb.com', 'username': 'dpercy'}

Message: SERVER-71524 [CQF] Don't use one ixscan for two independent traverses
Branch: master
https://github.com/mongodb/mongo/commit/afcba3c5c0d7214ea222dc7e56a897864023aabe

Comment by Githook User [ 07/Dec/22 ]

Author:

{'name': 'Sviatlana Zuiko', 'email': 'sviatlana.zuiko@mongodb.com', 'username': 'szuiko'}

Message: Revert "SERVER-71524 [CQF] Don't use one ixscan for two independent traverses"

This reverts commit c6028eadf56b1774688da9d188d3180af3b91cea.
Branch: master
https://github.com/mongodb/mongo/commit/0c7c2381eac77d9484d664eb4b5c7f11a4d946b3

Comment by Githook User [ 07/Dec/22 ]

Author:

{'name': 'David Percy', 'email': 'david.percy@mongodb.com', 'username': 'dpercy'}

Message: SERVER-71524 [CQF] Don't use one ixscan for two independent traverses
Branch: master
https://github.com/mongodb/mongo/commit/c6028eadf56b1774688da9d188d3180af3b91cea

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