Skip to content

Conversation

@WaVEV
Copy link
Collaborator

@WaVEV WaVEV commented Nov 3, 2025

Summary

This PR introduces support for extracting “pushable” conditions from a Django WhereNode. Pushable conditions are simple field predicates that can be applied earlier in the MongoDB pipeline.

Changes in this PR

  • Added _get_pushable_conditions() to collect pushable predicates per alias.

Test Plan

  • Added unit tests covering:
  • Django unit test.
  • Test to check semantic and the query generation
    • AND vs OR behavior
    • mixed branches with pushable and non-pushable predicates

Focus Areas for Reviewer

  • Correctness of connector flipping under negation (De Morgan application).
  • Behavior of shared-alias filtering under OR branches.

Checklist for Reviewer @timgraham @Jibola @aclark4life

  • Does the title of the PR reference a JIRA Ticket?
  • Do you fully understand the implementation? (Would you be comfortable explaining how this code works to someone else? docs here)
  • Have you checked for spelling & grammar errors?
  • Is all relevant documentation (README or docstring) updated?

@WaVEV WaVEV force-pushed the INTPYTHON-713-Push-conditions-into-lookup branch 3 times, most recently from 184d5e6 to 73bfed5 Compare November 9, 2025 21:02
@Jibola Jibola changed the title Push conditions into lookup when is possible. INTPYTHON-793: Push conditions into lookup when is possible. Nov 11, 2025
@WaVEV WaVEV force-pushed the INTPYTHON-713-Push-conditions-into-lookup branch 3 times, most recently from 9f056bf to 694368e Compare November 18, 2025 00:10
@aclark4life aclark4life changed the title INTPYTHON-793: Push conditions into lookup when is possible. INTPYTHON-793: Push conditions into lookup when possible. Nov 18, 2025
@WaVEV WaVEV force-pushed the INTPYTHON-713-Push-conditions-into-lookup branch from 694368e to 3e20747 Compare November 18, 2025 01:42
@WaVEV WaVEV marked this pull request as ready for review November 18, 2025 02:09
@WaVEV WaVEV force-pushed the INTPYTHON-713-Push-conditions-into-lookup branch from c51de5e to 8e6faea Compare December 2, 2025 03:30
@timgraham timgraham changed the title INTPYTHON-793: Push conditions into lookup when possible. INTPYTHON-793 Improve join performance by pushing complex filter conditions to $lookup Dec 2, 2025
@timgraham timgraham force-pushed the INTPYTHON-713-Push-conditions-into-lookup branch from 8e6faea to 86771d5 Compare December 2, 2025 15:42
@timgraham
Copy link
Collaborator

The tests were in M2MLookupConditionPushdownTests. I moved them to FKLookupConditionPushdownTests. Okay?

@timgraham timgraham merged commit 86771d5 into mongodb:main Dec 4, 2025
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants