[SERVER-58888] $unionWith explain with mode "executionStats" does not account for stages which are pushed down Created: 27/Jul/21  Updated: 29/Oct/23  Resolved: 30/Jul/21

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 4.4.11, 5.0.4, 5.1.0-rc0

Type: Bug Priority: Major - P3
Reporter: Nicholas Zolnierz Assignee: Nicholas Zolnierz
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
Problem/Incident
is caused by SERVER-50246 $unionWith explain loses information ... Closed
Related
is related to SERVER-50597 Explain against a pipeline containing... Backlog
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v5.0, v4.4
Participants:

 Description   

This is very similar to SERVER-50246, however in that case there was no document source rewrite taking place per se but simply executing the sub-pipeline as part of explain was losing stages in the sub-pipeline that were eligible to push into the find layer. For instance, SERVER-50246 would fix an issue like this:

[{$unionWith: {coll: "test", pipeline: [{$match: {_id: 1}}]}}]

However, there was an oversight with the implementation whereby the inner $match can actually come from a rewrite for a pipeline like this:

[{$unionWith: "test"}, {$match: {_id: 1}}]

which gets optimized to:

[{$match: {_id: 1}}, {$unionWith: {coll: "test", pipeline: [{$match: {_id: 1}}]}}]

The current explain output for the second example does not include the $match pushdown, and subsequently may not show the correct access plan (e.g. IXSCAN on _id).



 Comments   
Comment by Githook User [ 19/Oct/21 ]

Author:

{'name': 'Nick Zolnierz', 'email': 'nicholas.zolnierz@mongodb.com', 'username': 'nzolnierzmdb'}

Message: SERVER-58888 Account for pushed down stages in union explain with mode 'executionStats'

(cherry picked from commit 432d231645aa6496a291996a1385409b08bcd7dc)
Branch: v4.4
https://github.com/mongodb/mongo/commit/ee770884c22830f4c7881eefecbf55f00594d6fe

Comment by Githook User [ 18/Oct/21 ]

Author:

{'name': 'Nick Zolnierz', 'email': 'nicholas.zolnierz@mongodb.com', 'username': 'nzolnierzmdb'}

Message: SERVER-58888 Account for pushed down stages in union explain with mode 'executionStats'

(cherry picked from commit 432d231645aa6496a291996a1385409b08bcd7dc)
Branch: v5.0
https://github.com/mongodb/mongo/commit/3b3e3b67c68cab912eaa99b471d086cac70215da

Comment by Vivian Ge (Inactive) [ 06/Oct/21 ]

Updating the fixversion since branching activities occurred yesterday. This ticket will be in rc0 when it’s been triggered. For more active release information, please keep an eye on #server-release. Thank you!

Comment by Githook User [ 30/Jul/21 ]

Author:

{'name': 'Nick Zolnierz', 'email': 'nicholas.zolnierz@mongodb.com', 'username': 'nzolnierzmdb'}

Message: SERVER-58888 Account for pushed down stages in union explain with mode 'executionStats'
Branch: master
https://github.com/mongodb/mongo/commit/432d231645aa6496a291996a1385409b08bcd7dc

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